aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorKitto Flora2009-09-30 19:07:18 +0200
committerKitto Flora2009-09-30 19:07:18 +0200
commit07df0e0ab0c69633a6afec8d05cccc117656d3d9 (patch)
tree3048cc38b313e255cbf03fa3e2900e28cadc47c9 /OpenSim
parentAnd another merge issue (diff)
parentFix loading modules with alternate configurations and ports into ROBUST. (diff)
downloadopensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.zip
opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.gz
opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.bz2
opensim-SC_OLD-07df0e0ab0c69633a6afec8d05cccc117656d3d9.tar.xz
Merge branch '0.6.7-post-fixes' into vehicles
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs4
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs3
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs2
-rw-r--r--OpenSim/Client/Linden/LLProxyLoginModule.cs2
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs2
-rw-r--r--OpenSim/Data/IRegionData.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs38
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs2
-rw-r--r--OpenSim/Data/MySQL/Resources/004_GridStore.sql6
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs6
-rw-r--r--OpenSim/Framework/Communications/IUserService.cs16
-rw-r--r--OpenSim/Framework/Communications/Services/LoginService.cs5
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs5
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs32
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs19
-rw-r--r--OpenSim/Framework/RegionInfo.cs71
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs90
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs11
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs3
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs4
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs4
-rw-r--r--OpenSim/Framework/Util.cs33
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserManager.cs56
-rw-r--r--OpenSim/Grid/UserServer/Main.cs4
-rw-r--r--OpenSim/Region/Application/OpenSim.cs2
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs8
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs3
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs19
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs33
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs32
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs42
-rw-r--r--OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs15
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs265
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs129
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs303
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs560
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs86
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs183
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs131
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs65
-rw-r--r--OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs7
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs234
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs87
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs69
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs27
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMesh.cs14
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs103
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs28
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs8
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs13
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs12
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs11
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Base/ServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs14
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs61
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs433
-rw-r--r--OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs112
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs11
-rw-r--r--OpenSim/Server/Handlers/Land/LandServiceInConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs2
-rw-r--r--OpenSim/Server/ServerMain.cs50
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs6
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs6
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs6
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs448
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs152
-rw-r--r--OpenSim/Services/GridService/GridService.cs202
-rw-r--r--OpenSim/Services/GridService/GridServiceBase.cs22
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs245
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs177
-rw-r--r--OpenSim/Tests/Clients/Grid/GridForm.html11
86 files changed, 4314 insertions, 658 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
index 13f6426..db62d52 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
@@ -207,7 +207,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
207 // This plugin will only be enabled if the broader 207 // This plugin will only be enabled if the broader
208 // REST plugin mechanism is enabled. 208 // REST plugin mechanism is enabled.
209 209
210 Rest.Log.InfoFormat("{0} Plugin is initializing", MsgId); 210 //Rest.Log.InfoFormat("{0} Plugin is initializing", MsgId);
211 211
212 base.Initialise(openSim); 212 base.Initialise(openSim);
213 213
@@ -216,7 +216,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
216 216
217 if (!IsEnabled) 217 if (!IsEnabled)
218 { 218 {
219 Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId); 219 //Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId);
220 return; 220 return;
221 } 221 }
222 222
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
index f790c5e..02ef588 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
@@ -68,9 +68,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
68 base.Initialise(openSim); 68 base.Initialise(openSim);
69 if (!IsEnabled) 69 if (!IsEnabled)
70 { 70 {
71 m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID); 71 //m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
72 return; 72 return;
73 } 73 }
74
74 m_log.InfoFormat("{0} REST region plugin enabled", MsgID); 75 m_log.InfoFormat("{0} REST region plugin enabled", MsgID);
75 76
76 // add REST method handlers 77 // add REST method handlers
diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
index fd23384..ff1502a 100644
--- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
@@ -216,7 +216,7 @@ namespace OpenSim.ApplicationPlugins.Rest
216 216
217 if (!_config.GetBoolean("enabled", false)) 217 if (!_config.GetBoolean("enabled", false))
218 { 218 {
219 m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID); 219 //m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
220 return; 220 return;
221 } 221 }
222 222
diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs
index f55d9fc..ccd38d4 100644
--- a/OpenSim/Client/Linden/LLProxyLoginModule.cs
+++ b/OpenSim/Client/Linden/LLProxyLoginModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Client.Linden
58 { 58 {
59 if (m_firstScene != null) 59 if (m_firstScene != null)
60 { 60 {
61 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 61 return m_firstScene.SceneGridService.RegionLoginsEnabled;
62 } 62 }
63 else 63 else
64 { 64 {
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
index 4a31e95..fb0aaa5 100644
--- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
+++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Client.Linden
62 { 62 {
63 if (m_firstScene != null) 63 if (m_firstScene != null)
64 { 64 {
65 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 65 return m_firstScene.SceneGridService.RegionLoginsEnabled;
66 } 66 }
67 else 67 else
68 { 68 {
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs
index c5201ea..7a607ab 100644
--- a/OpenSim/Data/IRegionData.cs
+++ b/OpenSim/Data/IRegionData.cs
@@ -39,6 +39,8 @@ namespace OpenSim.Data
39 public string RegionName; 39 public string RegionName;
40 public int posX; 40 public int posX;
41 public int posY; 41 public int posY;
42 public int sizeX;
43 public int sizeY;
42 public Dictionary<string, object> Data; 44 public Dictionary<string, object> Data;
43 } 45 }
44 46
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index ced26a4..06ef624 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private List<string> m_ColumnNames = null; 41 private List<string> m_ColumnNames = null;
42 private int m_LastExpire = 0; 42// private int m_LastExpire = 0;
43 43
44 public MySqlRegionData(string connectionString, string realm) 44 public MySqlRegionData(string connectionString, string realm)
45 : base(connectionString) 45 : base(connectionString)
@@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL
77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
78 78
79 List<RegionData> ret = RunCommand(cmd); 79 List<RegionData> ret = RunCommand(cmd);
80 if (ret == null) 80 if (ret.Count == 0)
81 return null; 81 return null;
82 82
83 return ret[0]; 83 return ret[0];
@@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL
95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
96 96
97 List<RegionData> ret = RunCommand(cmd); 97 List<RegionData> ret = RunCommand(cmd);
98 if (ret == null) 98 if (ret.Count == 0)
99 return null; 99 return null;
100 100
101 return ret[0]; 101 return ret[0];
@@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL
138 ret.RegionName = result["regionName"].ToString(); 138 ret.RegionName = result["regionName"].ToString();
139 ret.posX = Convert.ToInt32(result["locX"]); 139 ret.posX = Convert.ToInt32(result["locX"]);
140 ret.posY = Convert.ToInt32(result["locY"]); 140 ret.posY = Convert.ToInt32(result["locY"]);
141 ret.sizeX = Convert.ToInt32(result["sizeX"]);
142 ret.sizeY = Convert.ToInt32(result["sizeY"]);
141 143
142 if (m_ColumnNames == null) 144 if (m_ColumnNames == null)
143 { 145 {
@@ -170,10 +172,7 @@ namespace OpenSim.Data.MySQL
170 result.Close(); 172 result.Close();
171 CloseReaderCommand(cmd); 173 CloseReaderCommand(cmd);
172 174
173 if (retList.Count > 0) 175 return retList;
174 return retList;
175
176 return null;
177 } 176 }
178 177
179 public bool Store(RegionData data) 178 public bool Store(RegionData data)
@@ -188,21 +187,25 @@ namespace OpenSim.Data.MySQL
188 data.Data.Remove("posX"); 187 data.Data.Remove("posX");
189 if (data.Data.ContainsKey("posY")) 188 if (data.Data.ContainsKey("posY"))
190 data.Data.Remove("posY"); 189 data.Data.Remove("posY");
190 if (data.Data.ContainsKey("sizeX"))
191 data.Data.Remove("sizeX");
192 if (data.Data.ContainsKey("sizeY"))
193 data.Data.Remove("sizeY");
194 if (data.Data.ContainsKey("locX"))
195 data.Data.Remove("locX");
196 if (data.Data.ContainsKey("locY"))
197 data.Data.Remove("locY");
191 198
192 string[] fields = new List<string>(data.Data.Keys).ToArray(); 199 string[] fields = new List<string>(data.Data.Keys).ToArray();
193 200
194 MySqlCommand cmd = new MySqlCommand(); 201 MySqlCommand cmd = new MySqlCommand();
195 202
196 string update = "update `"+m_Realm+"` set "; 203 string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
197 bool first = true;
198 foreach (string field in fields) 204 foreach (string field in fields)
199 { 205 {
200 if (!first) 206 update += ", ";
201 update += ", ";
202 update += "`" + field + "` = ?"+field; 207 update += "`" + field + "` = ?"+field;
203 208
204 first = false;
205
206 cmd.Parameters.AddWithValue("?"+field, data.Data[field]); 209 cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
207 } 210 }
208 211
@@ -213,13 +216,18 @@ namespace OpenSim.Data.MySQL
213 216
214 cmd.CommandText = update; 217 cmd.CommandText = update;
215 cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); 218 cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
219 cmd.Parameters.AddWithValue("?regionName", data.RegionName);
216 cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); 220 cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
221 cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
222 cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
223 cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
224 cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
217 225
218 if (ExecuteNonQuery(cmd) < 1) 226 if (ExecuteNonQuery(cmd) < 1)
219 { 227 {
220 string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + 228 string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
221 String.Join("`, `", fields) + 229 String.Join("`, `", fields) +
222 "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; 230 "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
223 231
224 cmd.CommandText = insert; 232 cmd.CommandText = insert;
225 233
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index 39d60ca..5352727 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private List<string> m_ColumnNames = null; 41 private List<string> m_ColumnNames = null;
42 private int m_LastExpire = 0; 42// private int m_LastExpire = 0;
43 43
44 public MySqlUserAccountData(string connectionString, string realm) 44 public MySqlUserAccountData(string connectionString, string realm)
45 : base(connectionString) 45 : base(connectionString)
diff --git a/OpenSim/Data/MySQL/Resources/004_GridStore.sql b/OpenSim/Data/MySQL/Resources/004_GridStore.sql
new file mode 100644
index 0000000..2238a88
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/004_GridStore.sql
@@ -0,0 +1,6 @@
1BEGIN;
2
3ALTER TABLE regions add column sizeX integer not null default 0;
4ALTER TABLE regions add column sizeY integer not null default 0;
5
6COMMIT;
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index 588b8ac..218fcd0 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Data.Null
40 40
41 public NullRegionData(string connectionString, string realm) 41 public NullRegionData(string connectionString, string realm)
42 { 42 {
43 //Console.WriteLine("[XXX] NullRegionData constructor");
43 } 44 }
44 45
45 public List<RegionData> Get(string regionName, UUID scopeID) 46 public List<RegionData> Get(string regionName, UUID scopeID)
@@ -100,10 +101,7 @@ namespace OpenSim.Data.Null
100 ret.Add(r); 101 ret.Add(r);
101 } 102 }
102 103
103 if (ret.Count > 0) 104 return ret;
104 return ret;
105
106 return null;
107 } 105 }
108 106
109 public bool Store(RegionData data) 107 public bool Store(RegionData data)
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 725225d..15c5a96 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Framework.Communications
98 /// <param name="friendlistowner">The agent that who's friends list is being updated</param> 98 /// <param name="friendlistowner">The agent that who's friends list is being updated</param>
99 /// <param name="friend">The agent that is getting or loosing permissions</param> 99 /// <param name="friend">The agent that is getting or loosing permissions</param>
100 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param> 100 /// <param name="perms">A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects </param>
101 void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms); 101 void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
102 102
103 /// <summary> 103 /// <summary>
104 /// Logs off a user on the user server 104 /// Logs off a user on the user server
@@ -137,9 +137,21 @@ namespace OpenSim.Framework.Communications
137 // But since Scenes only have IUserService references, I'm placing it here for now. 137 // But since Scenes only have IUserService references, I'm placing it here for now.
138 bool VerifySession(UUID userID, UUID sessionID); 138 bool VerifySession(UUID userID, UUID sessionID);
139 139
140 /// <summary>
141 /// Authenticate a user by their password.
142 /// </summary>
143 ///
144 /// This is used by callers outside the login process that want to
145 /// verify a user who has given their password.
146 ///
147 /// This should probably also be in IAuthentication but is here for the same reasons as VerifySession() is
148 ///
149 /// <param name="userID"></param>
150 /// <param name="password"></param>
151 /// <returns></returns>
152 bool AuthenticateUserByPassword(UUID userID, string password);
140 153
141 // Temporary Hack until we move everything to the new service model 154 // Temporary Hack until we move everything to the new service model
142 void SetInventoryService(IInventoryService invService); 155 void SetInventoryService(IInventoryService invService);
143
144 } 156 }
145} 157}
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs
index bf59f8e..a6cd918 100644
--- a/OpenSim/Framework/Communications/Services/LoginService.cs
+++ b/OpenSim/Framework/Communications/Services/LoginService.cs
@@ -1221,11 +1221,13 @@ namespace OpenSim.Framework.Communications.Services
1221 { 1221 {
1222 return Util.CreateUnknownUserErrorResponse(); 1222 return Util.CreateUnknownUserErrorResponse();
1223 } 1223 }
1224
1224 UUID.TryParse((string)requestData["session_id"], out guess_sid); 1225 UUID.TryParse((string)requestData["session_id"], out guess_sid);
1225 if (guess_sid == UUID.Zero) 1226 if (guess_sid == UUID.Zero)
1226 { 1227 {
1227 return Util.CreateUnknownUserErrorResponse(); 1228 return Util.CreateUnknownUserErrorResponse();
1228 } 1229 }
1230
1229 if (m_userManager.VerifySession(guess_aid, guess_sid)) 1231 if (m_userManager.VerifySession(guess_aid, guess_sid))
1230 { 1232 {
1231 authed = "TRUE"; 1233 authed = "TRUE";
@@ -1243,6 +1245,5 @@ namespace OpenSim.Framework.Communications.Services
1243 response.Value = responseData; 1245 response.Value = responseData;
1244 return response; 1246 return response;
1245 } 1247 }
1246
1247 } 1248 }
1248} 1249} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
index ac0dc6d..a757282 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -149,6 +149,11 @@ namespace OpenSim.Framework.Communications.Tests
149 { 149 {
150 throw new NotImplementedException(); 150 throw new NotImplementedException();
151 } 151 }
152
153 public virtual bool AuthenticateUserByPassword(UUID userID, string password)
154 {
155 throw new NotImplementedException();
156 }
152 } 157 }
153 } 158 }
154} 159}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 58174a0..1abd733 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -44,7 +44,8 @@ namespace OpenSim.Framework.Communications
44 /// <summary> 44 /// <summary>
45 /// Base class for user management (create, read, etc) 45 /// Base class for user management (create, read, etc)
46 /// </summary> 46 /// </summary>
47 public abstract class UserManagerBase : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication 47 public abstract class UserManagerBase
48 : IUserService, IUserAdminService, IAvatarService, IMessagingService, IAuthentication
48 { 49 {
49 private static readonly ILog m_log 50 private static readonly ILog m_log
50 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -93,9 +94,9 @@ namespace OpenSim.Framework.Communications
93 public void AddPlugin(string provider, string connect) 94 public void AddPlugin(string provider, string connect)
94 { 95 {
95 m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IUserDataPlugin>(provider, connect)); 96 m_plugins.AddRange(DataPluginFactory.LoadDataPlugins<IUserDataPlugin>(provider, connect));
96 } 97 }
97 98
98 #region UserProfile 99 #region UserProfile
99 100
100 public virtual void AddTemporaryUserProfile(UserProfileData userProfile) 101 public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
101 { 102 {
@@ -891,7 +892,10 @@ namespace OpenSim.Framework.Communications
891 892
892 if (userProfile != null && userProfile.CurrentAgent != null) 893 if (userProfile != null && userProfile.CurrentAgent != null)
893 { 894 {
894 m_log.DebugFormat("[USER AUTH]: Verifying session {0} for {1}; current session {2}", sessionID, userID, userProfile.CurrentAgent.SessionID); 895 m_log.DebugFormat(
896 "[USER AUTH]: Verifying session {0} for {1}; current session {2}",
897 sessionID, userID, userProfile.CurrentAgent.SessionID);
898
895 if (userProfile.CurrentAgent.SessionID == sessionID) 899 if (userProfile.CurrentAgent.SessionID == sessionID)
896 { 900 {
897 return true; 901 return true;
@@ -901,6 +905,26 @@ namespace OpenSim.Framework.Communications
901 return false; 905 return false;
902 } 906 }
903 907
908 public virtual bool AuthenticateUserByPassword(UUID userID, string password)
909 {
910// m_log.DebugFormat("[USER AUTH]: Authenticating user {0} given password {1}", userID, password);
911
912 UserProfileData userProfile = GetUserProfile(userID);
913
914 if (null == userProfile)
915 return false;
916
917 string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt);
918
919// m_log.DebugFormat(
920// "[USER AUTH]: Submitted hash {0}, stored hash {1}", md5PasswordHash, userProfile.PasswordHash);
921
922 if (md5PasswordHash == userProfile.PasswordHash)
923 return true;
924 else
925 return false;
926 }
927
904 #endregion 928 #endregion
905 } 929 }
906} 930}
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index 67bff4c..c27072c 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -197,8 +197,8 @@ namespace OpenSim.Framework.Console
197 197
198 string uri = "/ReadResponses/" + sessionID.ToString() + "/"; 198 string uri = "/ReadResponses/" + sessionID.ToString() + "/";
199 199
200 m_Server.AddPollServiceHTTPHandler(uri, HandleHttpCloseSession, 200 m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll,
201 new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, 201 new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents,
202 sessionID)); 202 sessionID));
203 203
204 XmlDocument xmldoc = new XmlDocument(); 204 XmlDocument xmldoc = new XmlDocument();
@@ -230,6 +230,11 @@ namespace OpenSim.Framework.Console
230 return reply; 230 return reply;
231 } 231 }
232 232
233 private Hashtable HandleHttpPoll(Hashtable request)
234 {
235 return new Hashtable();
236 }
237
233 private Hashtable HandleHttpCloseSession(Hashtable request) 238 private Hashtable HandleHttpCloseSession(Hashtable request)
234 { 239 {
235 DoExpire(); 240 DoExpire();
@@ -365,7 +370,7 @@ namespace OpenSim.Framework.Console
365 } 370 }
366 } 371 }
367 372
368 private bool HasEvents(UUID sessionID) 373 private bool HasEvents(UUID RequestID, UUID sessionID)
369 { 374 {
370 ConsoleConnection c = null; 375 ConsoleConnection c = null;
371 376
@@ -381,19 +386,19 @@ namespace OpenSim.Framework.Console
381 return false; 386 return false;
382 } 387 }
383 388
384 private Hashtable GetEvents(UUID sessionID, string request) 389 private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request)
385 { 390 {
386 ConsoleConnection c = null; 391 ConsoleConnection c = null;
387 392
388 lock (m_Connections) 393 lock (m_Connections)
389 { 394 {
390 if (!m_Connections.ContainsKey(sessionID)) 395 if (!m_Connections.ContainsKey(sessionID))
391 return NoEvents(); 396 return NoEvents(RequestID, UUID.Zero);
392 c = m_Connections[sessionID]; 397 c = m_Connections[sessionID];
393 } 398 }
394 c.last = System.Environment.TickCount; 399 c.last = System.Environment.TickCount;
395 if (c.lastLineSeen >= m_LineNumber) 400 if (c.lastLineSeen >= m_LineNumber)
396 return NoEvents(); 401 return NoEvents(RequestID, UUID.Zero);
397 402
398 Hashtable result = new Hashtable(); 403 Hashtable result = new Hashtable();
399 404
@@ -435,7 +440,7 @@ namespace OpenSim.Framework.Console
435 return result; 440 return result;
436 } 441 }
437 442
438 private Hashtable NoEvents() 443 private Hashtable NoEvents(UUID RequestID, UUID id)
439 { 444 {
440 Hashtable result = new Hashtable(); 445 Hashtable result = new Hashtable();
441 446
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 3896a6e..cee1d4b 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Net; 30using System.Net;
30using System.Net.Sockets; 31using System.Net.Sockets;
31using System.Xml; 32using System.Xml;
@@ -63,6 +64,13 @@ namespace OpenSim.Framework
63 } 64 }
64 protected string m_serverURI; 65 protected string m_serverURI;
65 66
67 public string RegionName
68 {
69 get { return m_regionName; }
70 set { m_regionName = value; }
71 }
72 protected string m_regionName = String.Empty;
73
66 protected bool Allow_Alternate_Ports; 74 protected bool Allow_Alternate_Ports;
67 public bool m_allow_alternate_ports; 75 public bool m_allow_alternate_ports;
68 protected string m_externalHostName; 76 protected string m_externalHostName;
@@ -100,6 +108,7 @@ namespace OpenSim.Framework
100 108
101 public SimpleRegionInfo(RegionInfo ConvertFrom) 109 public SimpleRegionInfo(RegionInfo ConvertFrom)
102 { 110 {
111 m_regionName = ConvertFrom.RegionName;
103 m_regionLocX = ConvertFrom.RegionLocX; 112 m_regionLocX = ConvertFrom.RegionLocX;
104 m_regionLocY = ConvertFrom.RegionLocY; 113 m_regionLocY = ConvertFrom.RegionLocY;
105 m_internalEndPoint = ConvertFrom.InternalEndPoint; 114 m_internalEndPoint = ConvertFrom.InternalEndPoint;
@@ -197,6 +206,67 @@ namespace OpenSim.Framework
197 { 206 {
198 return m_internalEndPoint.Port; 207 return m_internalEndPoint.Port;
199 } 208 }
209
210 public Dictionary<string, object> ToKeyValuePairs()
211 {
212 Dictionary<string, object> kvp = new Dictionary<string, object>();
213 kvp["uuid"] = RegionID.ToString();
214 kvp["locX"] = RegionLocX.ToString();
215 kvp["locY"] = RegionLocY.ToString();
216 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
217 kvp["external_port"] = ExternalEndPoint.Port.ToString();
218 kvp["external_host_name"] = ExternalHostName;
219 kvp["http_port"] = HttpPort.ToString();
220 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
221 kvp["internal_port"] = InternalEndPoint.Port.ToString();
222 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
223 kvp["server_uri"] = ServerURI;
224
225 return kvp;
226 }
227
228 public SimpleRegionInfo(Dictionary<string, object> kvp)
229 {
230 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
231 {
232 int port = 0;
233 Int32.TryParse((string)kvp["external_port"], out port);
234 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
235 ExternalEndPoint = ep;
236 }
237 else
238 ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
239
240 if (kvp["external_host_name"] != null)
241 ExternalHostName = (string)kvp["external_host_name"];
242
243 if (kvp["http_port"] != null)
244 {
245 UInt32 port = 0;
246 UInt32.TryParse((string)kvp["http_port"], out port);
247 HttpPort = port;
248 }
249
250 if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
251 {
252 int port = 0;
253 Int32.TryParse((string)kvp["internal_port"], out port);
254 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
255 InternalEndPoint = ep;
256 }
257 else
258 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
259
260 if (kvp["alternate_ports"] != null)
261 {
262 bool alts = false;
263 Boolean.TryParse((string)kvp["alternate_ports"], out alts);
264 m_allow_alternate_ports = alts;
265 }
266
267 if (kvp["server_uri"] != null)
268 ServerURI = (string)kvp["server_uri"];
269 }
200 } 270 }
201 271
202 public class RegionInfo : SimpleRegionInfo 272 public class RegionInfo : SimpleRegionInfo
@@ -222,7 +292,6 @@ namespace OpenSim.Framework
222 public UUID originRegionID = UUID.Zero; 292 public UUID originRegionID = UUID.Zero;
223 public string proxyUrl = ""; 293 public string proxyUrl = "";
224 public int ProxyOffset = 0; 294 public int ProxyOffset = 0;
225 public string RegionName = String.Empty;
226 public string regionSecret = UUID.Random().ToString(); 295 public string regionSecret = UUID.Random().ToString();
227 296
228 public string osSecret; 297 public string osSecret;
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 771ae05..01990fa 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -256,13 +256,51 @@ namespace OpenSim.Framework.Servers.HttpServer
256 IHttpClientContext context = (IHttpClientContext)source; 256 IHttpClientContext context = (IHttpClientContext)source;
257 IHttpRequest request = args.Request; 257 IHttpRequest request = args.Request;
258 258
259
260 PollServiceEventArgs psEvArgs; 259 PollServiceEventArgs psEvArgs;
260
261 if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) 261 if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs))
262 { 262 {
263 263 PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request);
264 m_PollServiceManager.Enqueue(new PollServiceHttpRequest(psEvArgs, context, request)); 264
265 //DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request))); 265 if (psEvArgs.Request != null)
266 {
267 OSHttpRequest req = new OSHttpRequest(context, request);
268
269 Stream requestStream = req.InputStream;
270
271 Encoding encoding = Encoding.UTF8;
272 StreamReader reader = new StreamReader(requestStream, encoding);
273
274 string requestBody = reader.ReadToEnd();
275
276 Hashtable keysvals = new Hashtable();
277 Hashtable headervals = new Hashtable();
278
279 string[] querystringkeys = req.QueryString.AllKeys;
280 string[] rHeaders = req.Headers.AllKeys;
281
282 keysvals.Add("body", requestBody);
283 keysvals.Add("uri", req.RawUrl);
284 keysvals.Add("content-type", req.ContentType);
285 keysvals.Add("http-method", req.HttpMethod);
286
287 foreach (string queryname in querystringkeys)
288 {
289 keysvals.Add(queryname, req.QueryString[queryname]);
290 }
291
292 foreach (string headername in rHeaders)
293 {
294 headervals[headername] = req.Headers[headername];
295 }
296
297 keysvals.Add("headers",headervals);
298 keysvals.Add("querystringkeys", querystringkeys);
299
300 psEvArgs.Request(psreq.RequestID, keysvals);
301 }
302
303 m_PollServiceManager.Enqueue(psreq);
266 } 304 }
267 else 305 else
268 { 306 {
@@ -275,48 +313,16 @@ namespace OpenSim.Framework.Servers.HttpServer
275 { 313 {
276 OSHttpRequest req = new OSHttpRequest(context, request); 314 OSHttpRequest req = new OSHttpRequest(context, request);
277 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 315 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
278 //resp.KeepAlive = req.KeepAlive;
279 //m_log.Info("[Debug BASE HTTP SERVER]: Got Request");
280 //HttpServerContextObj objstate= new HttpServerContextObj(req,resp);
281 //ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertIHttpClientContextToOSHttp), (object)objstate);
282 HandleRequest(req, resp); 316 HandleRequest(req, resp);
283 } 317 }
284 318
285 public void ConvertIHttpClientContextToOSHttp(object stateinfo) 319 public void ConvertIHttpClientContextToOSHttp(object stateinfo)
286 { 320 {
287 HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; 321 HttpServerContextObj objstate = (HttpServerContextObj)stateinfo;
288 //OSHttpRequest request = new OSHttpRequest(objstate.context,objstate.req);
289 //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
290 322
291 OSHttpRequest request = objstate.oreq; 323 OSHttpRequest request = objstate.oreq;
292 OSHttpResponse resp = objstate.oresp; 324 OSHttpResponse resp = objstate.oresp;
293 //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
294
295 /*
296 request.AcceptTypes = objstate.req.AcceptTypes;
297 request.ContentLength = (long)objstate.req.ContentLength;
298 request.Headers = objstate.req.Headers;
299 request.HttpMethod = objstate.req.Method;
300 request.InputStream = objstate.req.Body;
301 foreach (string str in request.Headers)
302 {
303 if (str.ToLower().Contains("content-type: "))
304 {
305 request.ContentType = str.Substring(13, str.Length - 13);
306 break;
307 }
308 }
309 //request.KeepAlive = objstate.req.
310 foreach (HttpServer.HttpInput httpinput in objstate.req.QueryString)
311 {
312 request.QueryString.Add(httpinput.Name, httpinput[httpinput.Name]);
313 }
314
315 //request.Query = objstate.req.//objstate.req.QueryString;
316 //foreach (
317 //request.QueryString = objstate.req.QueryString;
318 325
319 */
320 HandleRequest(request,resp); 326 HandleRequest(request,resp);
321 } 327 }
322 328
@@ -332,6 +338,7 @@ namespace OpenSim.Framework.Servers.HttpServer
332 // probability event; if a request is matched it is normally expected to be 338 // probability event; if a request is matched it is normally expected to be
333 // handled 339 // handled
334 //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); 340 //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl);
341
335 IHttpAgentHandler agentHandler; 342 IHttpAgentHandler agentHandler;
336 343
337 if (TryGetAgentHandler(request, response, out agentHandler)) 344 if (TryGetAgentHandler(request, response, out agentHandler))
@@ -342,10 +349,11 @@ namespace OpenSim.Framework.Servers.HttpServer
342 } 349 }
343 } 350 }
344 351
345 IRequestHandler requestHandler;
346 //response.KeepAlive = true; 352 //response.KeepAlive = true;
347 response.SendChunked = false; 353 response.SendChunked = false;
348 354
355 IRequestHandler requestHandler;
356
349 string path = request.RawUrl; 357 string path = request.RawUrl;
350 string handlerKey = GetHandlerKey(request.HttpMethod, path); 358 string handlerKey = GetHandlerKey(request.HttpMethod, path);
351 359
@@ -359,6 +367,7 @@ namespace OpenSim.Framework.Servers.HttpServer
359 367
360 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 368 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
361 369
370
362 if (requestHandler is IStreamedRequestHandler) 371 if (requestHandler is IStreamedRequestHandler)
363 { 372 {
364 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 373 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@@ -404,6 +413,7 @@ namespace OpenSim.Framework.Servers.HttpServer
404 // } 413 // }
405 414
406 keysvals.Add("requestbody", requestBody); 415 keysvals.Add("requestbody", requestBody);
416 keysvals.Add("headers",headervals);
407 if (keysvals.Contains("method")) 417 if (keysvals.Contains("method"))
408 { 418 {
409 //m_log.Warn("[HTTP]: Contains Method"); 419 //m_log.Warn("[HTTP]: Contains Method");
@@ -726,8 +736,11 @@ namespace OpenSim.Framework.Servers.HttpServer
726 else 736 else
727 { 737 {
728 xmlRpcResponse = new XmlRpcResponse(); 738 xmlRpcResponse = new XmlRpcResponse();
739
729 // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php 740 // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
730 xmlRpcResponse.SetFault(-32601, String.Format("Requested method [{0}] not found", methodName)); 741 xmlRpcResponse.SetFault(
742 XmlRpcErrorCodes.SERVER_ERROR_METHOD,
743 String.Format("Requested method [{0}] not found", methodName));
731 } 744 }
732 745
733 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); 746 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
@@ -747,6 +760,7 @@ namespace OpenSim.Framework.Servers.HttpServer
747 response.SendChunked = false; 760 response.SendChunked = false;
748 response.ContentLength64 = buf.Length; 761 response.ContentLength64 = buf.Length;
749 response.ContentEncoding = Encoding.UTF8; 762 response.ContentEncoding = Encoding.UTF8;
763
750 try 764 try
751 { 765 {
752 response.OutputStream.Write(buf, 0, buf.Length); 766 response.OutputStream.Write(buf, 0, buf.Length);
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index fed490e..9d512c6 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -30,20 +30,23 @@ using System.Collections;
30using OpenMetaverse; 30using OpenMetaverse;
31namespace OpenSim.Framework.Servers.HttpServer 31namespace OpenSim.Framework.Servers.HttpServer
32{ 32{
33 public delegate bool HasEventsMethod(UUID pId); 33 public delegate void RequestMethod(UUID requestID, Hashtable request);
34 public delegate bool HasEventsMethod(UUID requestID, UUID pId);
34 35
35 public delegate Hashtable GetEventsMethod(UUID pId, string request); 36 public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request);
36 37
37 public delegate Hashtable NoEventsMethod(); 38 public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId);
38 39
39 public class PollServiceEventArgs : EventArgs 40 public class PollServiceEventArgs : EventArgs
40 { 41 {
41 public HasEventsMethod HasEvents; 42 public HasEventsMethod HasEvents;
42 public GetEventsMethod GetEvents; 43 public GetEventsMethod GetEvents;
43 public NoEventsMethod NoEvents; 44 public NoEventsMethod NoEvents;
45 public RequestMethod Request;
44 public UUID Id; 46 public UUID Id;
45 public PollServiceEventArgs(HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) 47 public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId)
46 { 48 {
49 Request = pRequest;
47 HasEvents = pHasEvents; 50 HasEvents = pHasEvents;
48 GetEvents = pGetEvents; 51 GetEvents = pGetEvents;
49 NoEvents = pNoEvents; 52 NoEvents = pNoEvents;
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index ff7c1e8..553a7eb 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using HttpServer; 29using HttpServer;
30using OpenMetaverse;
30 31
31namespace OpenSim.Framework.Servers.HttpServer 32namespace OpenSim.Framework.Servers.HttpServer
32{ 33{
@@ -37,12 +38,14 @@ namespace OpenSim.Framework.Servers.HttpServer
37 public readonly IHttpClientContext HttpContext; 38 public readonly IHttpClientContext HttpContext;
38 public readonly IHttpRequest Request; 39 public readonly IHttpRequest Request;
39 public readonly int RequestTime; 40 public readonly int RequestTime;
41 public readonly UUID RequestID;
40 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) 42 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
41 { 43 {
42 PollServiceArgs = pPollServiceArgs; 44 PollServiceArgs = pPollServiceArgs;
43 HttpContext = pHttpContext; 45 HttpContext = pHttpContext;
44 Request = pRequest; 46 Request = pRequest;
45 RequestTime = System.Environment.TickCount; 47 RequestTime = System.Environment.TickCount;
48 RequestID = UUID.Random();
46 } 49 }
47 } 50 }
48} 51}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 4020190..1c54581 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -130,7 +130,7 @@ namespace OpenSim.Framework.Servers.HttpServer
130 foreach (object o in m_requests) 130 foreach (object o in m_requests)
131 { 131 {
132 PollServiceHttpRequest req = (PollServiceHttpRequest) o; 132 PollServiceHttpRequest req = (PollServiceHttpRequest) o;
133 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); 133 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
134 } 134 }
135 135
136 m_requests.Clear(); 136 m_requests.Clear();
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
index 41fb376..ce32443 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
@@ -100,11 +100,11 @@ namespace OpenSim.Framework.Servers.HttpServer
100 PollServiceHttpRequest req = m_request.Dequeue(); 100 PollServiceHttpRequest req = m_request.Dequeue();
101 try 101 try
102 { 102 {
103 if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id)) 103 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
104 { 104 {
105 StreamReader str = new StreamReader(req.Request.Body); 105 StreamReader str = new StreamReader(req.Request.Body);
106 106
107 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); 107 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
108 m_server.DoHTTPGruntWork(responsedata, 108 m_server.DoHTTPGruntWork(responsedata,
109 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); 109 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
110 } 110 }
@@ -112,7 +112,7 @@ namespace OpenSim.Framework.Servers.HttpServer
112 { 112 {
113 if ((Environment.TickCount - req.RequestTime) > m_timeout) 113 if ((Environment.TickCount - req.RequestTime) > m_timeout)
114 { 114 {
115 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), 115 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
116 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); 116 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
117 } 117 }
118 else 118 else
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
index 0f0c790..ebb2691 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -56,14 +56,14 @@ namespace OpenSim.Framework.Servers.HttpServer
56 request.ContentType = "text/www-form-urlencoded"; 56 request.ContentType = "text/www-form-urlencoded";
57 57
58 MemoryStream buffer = new MemoryStream(); 58 MemoryStream buffer = new MemoryStream();
59 59 int length = 0;
60 using (StreamWriter writer = new StreamWriter(buffer)) 60 using (StreamWriter writer = new StreamWriter(buffer))
61 { 61 {
62 writer.WriteLine(obj); 62 writer.WriteLine(obj);
63 writer.Flush(); 63 writer.Flush();
64 length = (int)buffer.Length;
64 } 65 }
65 66
66 int length = (int) buffer.Length;
67 request.ContentLength = length; 67 request.ContentLength = length;
68 68
69 Stream requestStream = request.GetRequestStream(); 69 Stream requestStream = request.GetRequestStream();
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 6f9b00c..22a660e 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,8 +29,8 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.6.6"; 32 private const string VERSION_NUMBER = "0.6.7";
33 private const Flavour VERSION_FLAVOUR = Flavour.Dev; 33 private const Flavour VERSION_FLAVOUR = Flavour.Release;
34 34
35 public enum Flavour 35 public enum Flavour
36 { 36 {
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 58344f3..45b5a10 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -70,6 +70,39 @@ namespace OpenSim.Framework
70 public static readonly Regex UUIDPattern 70 public static readonly Regex UUIDPattern
71 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); 71 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
72 72
73 /// <summary>
74 /// Linear interpolates B<->C using percent A
75 /// </summary>
76 /// <param name="a"></param>
77 /// <param name="b"></param>
78 /// <param name="c"></param>
79 /// <returns></returns>
80 public static double lerp(double a, double b, double c)
81 {
82 return (b*a) + (c*(1 - a));
83 }
84
85 /// <summary>
86 /// Bilinear Interpolate, see Lerp but for 2D using 'percents' X & Y.
87 /// Layout:
88 /// A B
89 /// C D
90 /// A<->C = Y
91 /// C<->D = X
92 /// </summary>
93 /// <param name="x"></param>
94 /// <param name="y"></param>
95 /// <param name="a"></param>
96 /// <param name="b"></param>
97 /// <param name="c"></param>
98 /// <param name="d"></param>
99 /// <returns></returns>
100 public static double lerp2D(double x, double y, double a, double b, double c, double d)
101 {
102 return lerp(y, lerp(x, a, b), lerp(x, c, d));
103 }
104
105
73 /// <value> 106 /// <value>
74 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) 107 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
75 /// </value> 108 /// </value>
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs
index 002f232..efbf45e 100644
--- a/OpenSim/Grid/UserServer.Modules/UserManager.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs
@@ -108,6 +108,9 @@ namespace OpenSim.Grid.UserServer.Modules
108 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); 108 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
109 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); 109 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
110 110
111 // Used by IAR module to do password checks
112 m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword);
113
111 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); 114 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
112 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); 115 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
113 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); 116 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
@@ -203,6 +206,57 @@ namespace OpenSim.Grid.UserServer.Modules
203 206
204 #region XMLRPC User Methods 207 #region XMLRPC User Methods
205 208
209 /// <summary>
210 /// Authenticate a user using their password
211 /// </summary>
212 /// <param name="request">Must contain values for "user_uuid" and "password" keys</param>
213 /// <param name="remoteClient"></param>
214 /// <returns></returns>
215 public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient)
216 {
217// m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient);
218
219 Hashtable requestData = (Hashtable)request.Params[0];
220 string userUuidRaw = (string)requestData["user_uuid"];
221 string password = (string)requestData["password"];
222
223 if (null == userUuidRaw)
224 return Util.CreateUnknownUserErrorResponse();
225
226 UUID userUuid;
227 if (!UUID.TryParse(userUuidRaw, out userUuid))
228 return Util.CreateUnknownUserErrorResponse();
229
230 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid);
231 if (null == userProfile)
232 return Util.CreateUnknownUserErrorResponse();
233
234 string authed;
235
236 if (null == password)
237 {
238 authed = "FALSE";
239 }
240 else
241 {
242 if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password))
243 authed = "TRUE";
244 else
245 authed = "FALSE";
246 }
247
248// m_log.DebugFormat(
249// "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}",
250// remoteClient, userUuid, authed);
251
252 XmlRpcResponse response = new XmlRpcResponse();
253 Hashtable responseData = new Hashtable();
254 responseData["auth_user"] = authed;
255 response.Value = responseData;
256
257 return response;
258 }
259
206 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient) 260 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient)
207 { 261 {
208 // XmlRpcResponse response = new XmlRpcResponse(); 262 // XmlRpcResponse response = new XmlRpcResponse();
@@ -246,10 +300,10 @@ namespace OpenSim.Grid.UserServer.Modules
246 m_userDataBaseService.CommitAgent(ref userProfile); 300 m_userDataBaseService.CommitAgent(ref userProfile);
247 //setUserProfile(userProfile); 301 //setUserProfile(userProfile);
248 302
249
250 returnstring = "TRUE"; 303 returnstring = "TRUE";
251 } 304 }
252 } 305 }
306
253 responseData.Add("returnString", returnstring); 307 responseData.Add("returnString", returnstring);
254 response.Value = responseData; 308 response.Value = responseData;
255 return response; 309 return response;
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index baf0fd3..a92226d 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -260,8 +260,6 @@ namespace OpenSim.Grid.UserServer
260 m_userManager.PostInitialise(); 260 m_userManager.PostInitialise();
261 m_avatarAppearanceModule.PostInitialise(); 261 m_avatarAppearanceModule.PostInitialise();
262 m_friendsModule.PostInitialise(); 262 m_friendsModule.PostInitialise();
263
264 m_avatarAppearanceModule.PostInitialise();
265 } 263 }
266 264
267 protected virtual void RegisterHttpHandlers() 265 protected virtual void RegisterHttpHandlers()
@@ -276,8 +274,6 @@ namespace OpenSim.Grid.UserServer
276 m_avatarAppearanceModule.RegisterHandlers(m_httpServer); 274 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
277 m_messagesService.RegisterHandlers(m_httpServer); 275 m_messagesService.RegisterHandlers(m_httpServer);
278 m_gridInfoService.RegisterHandlers(m_httpServer); 276 m_gridInfoService.RegisterHandlers(m_httpServer);
279
280 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
281 } 277 }
282 278
283 public override void ShutdownSpecific() 279 public override void ShutdownSpecific()
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 10071a0..e9c9dc1 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -557,7 +557,7 @@ namespace OpenSim
557 /// <param name="cmd"></param> 557 /// <param name="cmd"></param>
558 private void HandleLoginStatus(string module, string[] cmd) 558 private void HandleLoginStatus(string module, string[] cmd)
559 { 559 {
560 if (m_commsManager.GridService.RegionLoginsEnabled == false) 560 if (m_sceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled == false)
561 561
562 m_log.Info("[ Login ] Login are disabled "); 562 m_log.Info("[ Login ] Login are disabled ");
563 else 563 else
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 7bc0b77..4d13e83 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -209,9 +209,9 @@ namespace OpenSim
209 } 209 }
210 210
211 // Only enable logins to the regions once we have completely finished starting up (apart from scripts) 211 // Only enable logins to the regions once we have completely finished starting up (apart from scripts)
212 if ((m_commsManager != null) && (m_commsManager.GridService != null)) 212 if ((SceneManager.CurrentOrFirstScene != null) && (SceneManager.CurrentOrFirstScene.SceneGridService != null))
213 { 213 {
214 m_commsManager.GridService.RegionLoginsEnabled = true; 214 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
215 } 215 }
216 216
217 AddPluginCommands(); 217 AddPluginCommands();
@@ -299,12 +299,12 @@ namespace OpenSim
299 if (LoginEnabled) 299 if (LoginEnabled)
300 { 300 {
301 m_log.Info("[LOGIN]: Login is now enabled."); 301 m_log.Info("[LOGIN]: Login is now enabled.");
302 m_commsManager.GridService.RegionLoginsEnabled = true; 302 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
303 } 303 }
304 else 304 else
305 { 305 {
306 m_log.Info("[LOGIN]: Login is now disabled."); 306 m_log.Info("[LOGIN]: Login is now disabled.");
307 m_commsManager.GridService.RegionLoginsEnabled = false; 307 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = false;
308 } 308 }
309 } 309 }
310 310
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index f6ae639..912cbf1 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1664,6 +1664,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1664 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; 1664 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
1665 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; 1665 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
1666 enablesimpacket.SimulatorInfo.Port = neighbourPort; 1666 enablesimpacket.SimulatorInfo.Port = neighbourPort;
1667
1668 enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
1669
1667 OutPacket(enablesimpacket, ThrottleOutPacketType.Task); 1670 OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
1668 } 1671 }
1669 1672
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
index af4fb37..d18937e 100644
--- a/OpenSim/Region/Communications/Local/LocalUserServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -80,6 +80,21 @@ namespace OpenSim.Region.Communications.Local
80 throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running."); 80 throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running.");
81 } 81 }
82 return data; 82 return data;
83 } 83 }
84
85 public override bool AuthenticateUserByPassword(UUID userID, string password)
86 {
87 UserProfileData userProfile = GetUserProfile(userID);
88
89 if (null == userProfile)
90 return false;
91
92 string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt);
93
94 if (md5PasswordHash == userProfile.PasswordHash)
95 return true;
96 else
97 return false;
98 }
84 } 99 }
85} 100} \ No newline at end of file
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index dff8305..51ba2e9 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -140,6 +140,37 @@ namespace OpenSim.Region.Communications.OGS1
140 { 140 {
141 m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); 141 m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID);
142 return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); 142 return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
143 } 143 }
144
145 public override bool AuthenticateUserByPassword(UUID userID, string password)
146 {
147 Hashtable param = new Hashtable();
148 param["user_uuid"] = userID.ToString();
149 param["password"] = password;
150 IList parameters = new ArrayList();
151 parameters.Add(param);
152 XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters);
153 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000);
154
155 // Temporary measure to deal with older services
156 if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD)
157 {
158 throw new Exception(
159 String.Format(
160 "XMLRPC method 'authenticate_user_by_password' not yet implemented by user service at {0}",
161 m_commsManager.NetworkServersInfo.UserURL));
162 }
163
164 Hashtable respData = (Hashtable)resp.Value;
165
166 if ((string)respData["auth_user"] == "TRUE")
167 {
168 return true;
169 }
170 else
171 {
172 return false;
173 }
174 }
144 } 175 }
145} \ No newline at end of file 176} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index d85d3df..37cccc8 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -142,7 +142,7 @@ namespace Flotsam.RegionModules.AssetCache
142 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); 142 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
143 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); 143 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory);
144 144
145 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", true); 145 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
146 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); 146 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
147 147
148#if WAIT_ON_INPROGRESS_REQUESTS 148#if WAIT_ON_INPROGRESS_REQUESTS
@@ -150,7 +150,7 @@ namespace Flotsam.RegionModules.AssetCache
150#endif 150#endif
151 151
152 m_LogLevel = assetConfig.GetInt("LogLevel", 1); 152 m_LogLevel = assetConfig.GetInt("LogLevel", 1);
153 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1); 153 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
154 154
155 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); 155 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
156 m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); 156 m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration));
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 7b4a9eb..c6ebb24 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -118,6 +118,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
118 118
119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) 119 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
120 { 120 {
121 // We're almost done. Just need to write out the control file now
122 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
123 m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
124
121 Exception reportedException = null; 125 Exception reportedException = null;
122 bool succeeded = true; 126 bool succeeded = true;
123 127
@@ -320,7 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
320 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); 324 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar);
321 } 325 }
322 326
323 SaveUsers(); 327 // Don't put all this profile information into the archive right now.
328 //SaveUsers();
329
324 new AssetsRequest( 330 new AssetsRequest(
325 new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, 331 new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,
326 m_scene.AssetService, ReceivedAllAssets).Execute(); 332 m_scene.AssetService, ReceivedAllAssets).Execute();
@@ -409,5 +415,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
409 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, 415 ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
410 id); 416 id);
411 } 417 }
418
419 /// <summary>
420 /// Create the control file for a 0.1 version archive
421 /// </summary>
422 /// <returns></returns>
423 public static string Create0p1ControlFile()
424 {
425 StringWriter sw = new StringWriter();
426 XmlTextWriter xtw = new XmlTextWriter(sw);
427 xtw.Formatting = Formatting.Indented;
428 xtw.WriteStartDocument();
429 xtw.WriteStartElement("archive");
430 xtw.WriteAttributeString("major_version", "0");
431 xtw.WriteAttributeString("minor_version", "1");
432 xtw.WriteEndElement();
433
434 xtw.Flush();
435 xtw.Close();
436
437 String s = sw.ToString();
438 sw.Close();
439
440 return s;
441 }
412 } 442 }
413} \ No newline at end of file 443} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 196205c..55dce05 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -322,7 +322,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
322 /// <param name="pass">User password</param> 322 /// <param name="pass">User password</param>
323 /// <returns></returns> 323 /// <returns></returns>
324 protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) 324 protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass)
325 { 325 {
326 CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); 326 CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
327 //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName); 327 //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName);
328 if (null == userInfo) 328 if (null == userInfo)
@@ -333,29 +333,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
333 return null; 333 return null;
334 } 334 }
335 335
336 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); 336 try
337 337 {
338 if (userInfo.UserProfile.PasswordHash == null || userInfo.UserProfile.PasswordHash == String.Empty) 338 if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass))
339 { 339 {
340 m_log.ErrorFormat( 340 return userInfo;
341 "[INVENTORY ARCHIVER]: Sorry, the grid mode service is not providing password hash details for the check. This will be fixed in an OpenSim git revision soon"); 341 }
342 342 else
343 return null; 343 {
344 m_log.ErrorFormat(
345 "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
346 firstName, lastName);
347 return null;
348 }
344 } 349 }
345 350 catch (Exception e)
346// m_log.DebugFormat(
347// "[INVENTORY ARCHIVER]: received salt {0}, hash {1}, supplied hash {2}",
348// userInfo.UserProfile.PasswordSalt, userInfo.UserProfile.PasswordHash, md5PasswdHash);
349
350 if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
351 { 351 {
352 m_log.ErrorFormat( 352 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message);
353 "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
354 firstName, lastName);
355 return null; 353 return null;
356 } 354 }
357
358 return userInfo;
359 } 355 }
360 356
361 /// <summary> 357 /// <summary>
@@ -375,9 +371,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
375 { 371 {
376 foreach (InventoryNodeBase node in loadedNodes) 372 foreach (InventoryNodeBase node in loadedNodes)
377 { 373 {
378 m_log.DebugFormat( 374// m_log.DebugFormat(
379 "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", 375// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
380 user.Name, node.Name); 376// user.Name, node.Name);
381 377
382 user.ControllingClient.SendBulkUpdateInventory(node); 378 user.ControllingClient.SendBulkUpdateInventory(node);
383 } 379 }
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
index 34d46a0..0cdd9a8 100644
--- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
@@ -316,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
316 316
317 // This will persist this beyond the expiry of the caps handlers 317 // This will persist this beyond the expiry of the caps handlers
318 MainServer.Instance.AddPollServiceHTTPHandler( 318 MainServer.Instance.AddPollServiceHTTPHandler(
319 capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePath2, new PollServiceEventArgs(HasEvents, GetEvents, NoEvents, agentID)); 319 capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID));
320 320
321 Random rnd = new Random(Environment.TickCount); 321 Random rnd = new Random(Environment.TickCount);
322 lock (m_ids) 322 lock (m_ids)
@@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
326 } 326 }
327 } 327 }
328 328
329 public bool HasEvents(UUID agentID) 329 public bool HasEvents(UUID requestID, UUID agentID)
330 { 330 {
331 // Don't use this, because of race conditions at agent closing time 331 // Don't use this, because of race conditions at agent closing time
332 //Queue<OSD> queue = TryGetQueue(agentID); 332 //Queue<OSD> queue = TryGetQueue(agentID);
@@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
343 return false; 343 return false;
344 } 344 }
345 345
346 public Hashtable GetEvents(UUID pAgentId, string request) 346 public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
347 { 347 {
348 Queue<OSD> queue = TryGetQueue(pAgentId); 348 Queue<OSD> queue = TryGetQueue(pAgentId);
349 OSD element; 349 OSD element;
350 lock (queue) 350 lock (queue)
351 { 351 {
352 if (queue.Count == 0) 352 if (queue.Count == 0)
353 return NoEvents(); 353 return NoEvents(requestID, pAgentId);
354 element = queue.Dequeue(); // 15s timeout 354 element = queue.Dequeue(); // 15s timeout
355 } 355 }
356 356
@@ -398,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
398 //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); 398 //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
399 } 399 }
400 400
401 public Hashtable NoEvents() 401 public Hashtable NoEvents(UUID requestID, UUID agentID)
402 { 402 {
403 Hashtable responsedata = new Hashtable(); 403 Hashtable responsedata = new Hashtable();
404 responsedata["int_response_code"] = 502; 404 responsedata["int_response_code"] = 502;
@@ -491,6 +491,11 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
491 return responsedata; 491 return responsedata;
492 } 492 }
493 493
494 public Hashtable EventQueuePoll(Hashtable request)
495 {
496 return new Hashtable();
497 }
498
494 public Hashtable EventQueuePath2(Hashtable request) 499 public Hashtable EventQueuePath2(Hashtable request)
495 { 500 {
496 string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); 501 string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/","");
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
index 613dbe9..4199c98 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
61 { 61 {
62 if (m_firstScene != null) 62 if (m_firstScene != null)
63 { 63 {
64 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 64 return m_firstScene.SceneGridService.RegionLoginsEnabled;
65 } 65 }
66 else 66 else
67 { 67 {
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index f9e61aa..8f82718 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -38,11 +38,15 @@
38 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" /> 38 <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" />
39 <RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" /> 39 <RegionModule id="LocalInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.LocalInterregionComms" />
40 <RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" /> 40 <RegionModule id="RESTInterregionComms" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion.RESTInterregionComms" />
41 <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" />
42 <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" />
43 <RegionModule id="HGGridConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.HGGridConnector" />
41 <!-- Service connectors IN modules --> 44 <!-- Service connectors IN modules -->
42 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> 45 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
43 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 46 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
44 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> 47 <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" />
45 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ 48 <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \
49 <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.HypergridServiceInConnectorModule" /> \
46 50
47 </Extension> 51 </Extension>
48 52
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 6a2a6c8..b885420 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -55,14 +55,19 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
55 public UUID requestID; 55 public UUID requestID;
56 public Dictionary<string, string> headers; 56 public Dictionary<string, string> headers;
57 public string body; 57 public string body;
58 public int responseCode;
59 public string responseBody;
58 public ManualResetEvent ev; 60 public ManualResetEvent ev;
61 public bool requestDone;
62 public int startTime;
63 public string uri;
59 } 64 }
60 65
61 public class UrlModule : ISharedRegionModule, IUrlModule 66 public class UrlModule : ISharedRegionModule, IUrlModule
62 { 67 {
63// private static readonly ILog m_log = 68 private static readonly ILog m_log =
64// LogManager.GetLogger( 69 LogManager.GetLogger(
65// MethodBase.GetCurrentMethod().DeclaringType); 70 MethodBase.GetCurrentMethod().DeclaringType);
66 71
67 private Dictionary<UUID, UrlData> m_RequestMap = 72 private Dictionary<UUID, UrlData> m_RequestMap =
68 new Dictionary<UUID, UrlData>(); 73 new Dictionary<UUID, UrlData>();
@@ -70,15 +75,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
70 private Dictionary<string, UrlData> m_UrlMap = 75 private Dictionary<string, UrlData> m_UrlMap =
71 new Dictionary<string, UrlData>(); 76 new Dictionary<string, UrlData>();
72 77
78
73 private int m_TotalUrls = 100; 79 private int m_TotalUrls = 100;
74 80
75 private IHttpServer m_HttpServer = null; 81 private IHttpServer m_HttpServer = null;
76 82
83 private string m_ExternalHostNameForLSL = "";
84
77 public Type ReplaceableInterface 85 public Type ReplaceableInterface
78 { 86 {
79 get { return null; } 87 get { return null; }
80 } 88 }
81 89
90 private Hashtable HandleHttpPoll(Hashtable request)
91 {
92 return new Hashtable();
93 }
94
82 public string Name 95 public string Name
83 { 96 {
84 get { return "UrlModule"; } 97 get { return "UrlModule"; }
@@ -86,6 +99,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
86 99
87 public void Initialise(IConfigSource config) 100 public void Initialise(IConfigSource config)
88 { 101 {
102 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName);
89 } 103 }
90 104
91 public void PostInitialise() 105 public void PostInitialise()
@@ -117,7 +131,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
117 public void Close() 131 public void Close()
118 { 132 {
119 } 133 }
120
121 public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) 134 public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID)
122 { 135 {
123 UUID urlcode = UUID.Random(); 136 UUID urlcode = UUID.Random();
@@ -129,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
129 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 142 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
130 return urlcode; 143 return urlcode;
131 } 144 }
132 string url = "http://"+System.Environment.MachineName+":"+m_HttpServer.Port.ToString()+"/lslhttp/"+urlcode.ToString()+"/"; 145 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
133 146
134 UrlData urlData = new UrlData(); 147 UrlData urlData = new UrlData();
135 urlData.hostID = host.UUID; 148 urlData.hostID = host.UUID;
@@ -139,9 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
139 urlData.urlcode = urlcode; 152 urlData.urlcode = urlcode;
140 urlData.requests = new Dictionary<UUID, RequestData>(); 153 urlData.requests = new Dictionary<UUID, RequestData>();
141 154
155
142 m_UrlMap[url] = urlData; 156 m_UrlMap[url] = urlData;
143 157
144 m_HttpServer.AddHTTPHandler("/lslhttp/"+urlcode.ToString()+"/", HttpRequestHandler); 158 string uri = "/lslhttp/" + urlcode.ToString() + "/";
159
160 m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll,
161 new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents,
162 urlcode));
145 163
146 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); 164 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url });
147 } 165 }
@@ -165,7 +183,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
165 UrlData data; 183 UrlData data;
166 184
167 if (!m_UrlMap.TryGetValue(url, out data)) 185 if (!m_UrlMap.TryGetValue(url, out data))
186 {
168 return; 187 return;
188 }
169 189
170 foreach (UUID req in data.requests.Keys) 190 foreach (UUID req in data.requests.Keys)
171 m_RequestMap.Remove(req); 191 m_RequestMap.Remove(req);
@@ -174,13 +194,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
174 m_UrlMap.Remove(url); 194 m_UrlMap.Remove(url);
175 } 195 }
176 } 196 }
177 197
178 public void HttpResponse(UUID request, int status, string body) 198 public void HttpResponse(UUID request, int status, string body)
179 { 199 {
200 if (m_RequestMap.ContainsKey(request))
201 {
202 UrlData urlData = m_RequestMap[request];
203 urlData.requests[request].responseCode = status;
204 urlData.requests[request].responseBody = body;
205 //urlData.requests[request].ev.Set();
206 urlData.requests[request].requestDone =true;
207 }
208 else
209 {
210 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
211 }
180 } 212 }
181 213
182 public string GetHttpHeader(UUID request, string header) 214 public string GetHttpHeader(UUID requestId, string header)
183 { 215 {
216 if (m_RequestMap.ContainsKey(requestId))
217 {
218 UrlData urlData=m_RequestMap[requestId];
219 string value;
220 if (urlData.requests[requestId].headers.TryGetValue(header,out value))
221 return value;
222 }
223 else
224 {
225 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
226 }
184 return String.Empty; 227 return String.Empty;
185 } 228 }
186 229
@@ -233,26 +276,214 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
233 } 276 }
234 } 277 }
235 278
279
236 private void RemoveUrl(UrlData data) 280 private void RemoveUrl(UrlData data)
237 { 281 {
238 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); 282 m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
239 } 283 }
240 284
241 private Hashtable HttpRequestHandler(Hashtable request) 285 private Hashtable NoEvents(UUID requestID, UUID sessionID)
242 { 286 {
243 string uri = request["uri"].ToString(); 287 Hashtable response = new Hashtable();
244 //A solution to this ugly mess would be to use only the /lslhttp/<UUID>/ part of the URI as the key. 288 UrlData url;
245 UrlData url = m_UrlMap["http://"+System.Environment.MachineName+":"+m_HttpServer.Port.ToString()+uri]; 289 lock (m_RequestMap)
290 {
291 if (!m_RequestMap.ContainsKey(requestID))
292 return response;
293 url = m_RequestMap[requestID];
294 }
295
296 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
297 {
298 response["int_response_code"] = 500;
299 response["str_response_string"] = "Script timeout";
300 response["content_type"] = "text/plain";
301 response["keepalive"] = false;
302 response["reusecontext"] = false;
303
304 //remove from map
305 lock (url)
306 {
307 url.requests.Remove(requestID);
308 m_RequestMap.Remove(requestID);
309 }
310
311 return response;
312 }
313
314
315 return response;
316 }
317
318 private bool HasEvents(UUID requestID, UUID sessionID)
319 {
320 UrlData url=null;
246 321
247 //UUID.Random() below is a hack! Eventually we will do HTTP requests and responses properly. 322 lock (m_RequestMap)
248 url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { UUID.Random().ToString(), request["http-method"].ToString(), request["body"].ToString() }); 323 {
324 if (!m_RequestMap.ContainsKey(requestID))
325 {
326 return false;
327 }
328 url = m_RequestMap[requestID];
329 if (!url.requests.ContainsKey(requestID))
330 {
331 return false;
332 }
333 }
249 334
335 if (System.Environment.TickCount-url.requests[requestID].startTime>25000)
336 {
337 return true;
338 }
339
340 if (url.requests[requestID].requestDone)
341 return true;
342 else
343 return false;
344
345 }
346 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
347 {
348 UrlData url = null;
349 RequestData requestData = null;
350
351 lock (m_RequestMap)
352 {
353 if (!m_RequestMap.ContainsKey(requestID))
354 return NoEvents(requestID,sessionID);
355 url = m_RequestMap[requestID];
356 requestData = url.requests[requestID];
357 }
358
359 if (!requestData.requestDone)
360 return NoEvents(requestID,sessionID);
361
250 Hashtable response = new Hashtable(); 362 Hashtable response = new Hashtable();
251 response["int_response_code"] = 200; 363
252 response["str_response_string"] = "This is a generic response as OpenSim does not yet support proper responses. Your request has been passed to the object."; 364 if (System.Environment.TickCount - requestData.startTime > 25000)
365 {
366 response["int_response_code"] = 500;
367 response["str_response_string"] = "Script timeout";
368 response["content_type"] = "text/plain";
369 response["keepalive"] = false;
370 response["reusecontext"] = false;
371 return response;
372 }
373 //put response
374 response["int_response_code"] = requestData.responseCode;
375 response["str_response_string"] = requestData.responseBody;
376 response["content_type"] = "text/plain";
377 response["keepalive"] = false;
378 response["reusecontext"] = false;
379
380 //remove from map
381 lock (url)
382 {
383 url.requests.Remove(requestID);
384 m_RequestMap.Remove(requestID);
385 }
253 386
254 return response; 387 return response;
255 } 388 }
389 public void HttpRequestHandler(UUID requestID, Hashtable request)
390 {
391 lock (request)
392 {
393 string uri = request["uri"].ToString();
394
395 try
396 {
397 Hashtable headers = (Hashtable)request["headers"];
398
399// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/";
400
401 int pos1 = uri.IndexOf("/");// /lslhttp
402 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
403 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/
404 string uri_tmp = uri.Substring(0, pos3 + 1);
405 //HTTP server code doesn't provide us with QueryStrings
406 string pathInfo;
407 string queryString;
408 queryString = "";
409
410 pathInfo = uri.Substring(pos3);
411
412 UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp];
413
414 //for llGetHttpHeader support we need to store original URI here
415 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
416 //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader
417
418 RequestData requestData = new RequestData();
419 requestData.requestID = requestID;
420 requestData.requestDone = false;
421 requestData.startTime = System.Environment.TickCount;
422 requestData.uri = uri;
423 if (requestData.headers == null)
424 requestData.headers = new Dictionary<string, string>();
425
426 foreach (DictionaryEntry header in headers)
427 {
428 string key = (string)header.Key;
429 string value = (string)header.Value;
430 requestData.headers.Add(key, value);
431 }
432 foreach (DictionaryEntry de in request)
433 {
434 if (de.Key.ToString() == "querystringkeys")
435 {
436 System.String[] keys = (System.String[])de.Value;
437 foreach (String key in keys)
438 {
439 if (request.ContainsKey(key))
440 {
441 string val = (String)request[key];
442 queryString = queryString + key + "=" + val + "&";
443 }
444 }
445 if (queryString.Length > 1)
446 queryString = queryString.Substring(0, queryString.Length - 1);
447
448 }
449
450 }
451
452 //if this machine is behind DNAT/port forwarding, currently this is being
453 //set to address of port forwarding router
454 requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
455 requestData.headers["x-path-info"] = pathInfo;
456 requestData.headers["x-query-string"] = queryString;
457 requestData.headers["x-script-url"] = url.url;
458
459 requestData.ev = new ManualResetEvent(false);
460 lock (url.requests)
461 {
462 url.requests.Add(requestID, requestData);
463 }
464 lock (m_RequestMap)
465 {
466 //add to request map
467 m_RequestMap.Add(requestID, url);
468 }
469
470 url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
471
472 //send initial response?
473// Hashtable response = new Hashtable();
474
475 return;
476
477 }
478 catch (Exception we)
479 {
480 //Hashtable response = new Hashtable();
481 m_log.Warn("[HttpRequestHandler]: http-in request failed");
482 m_log.Warn(we.Message);
483 m_log.Warn(we.StackTrace);
484 }
485 }
486 }
256 487
257 private void OnScriptReset(uint localID, UUID itemID) 488 private void OnScriptReset(uint localID, UUID itemID)
258 { 489 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
new file mode 100644
index 0000000..4fbee7f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs
@@ -0,0 +1,129 @@
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.Reflection;
30using System.Collections.Generic;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Framework.Servers.HttpServer;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Server.Base;
38using OpenSim.Server.Handlers.Base;
39using OpenSim.Server.Handlers.Grid;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
42{
43 public class HypergridServiceInConnectorModule : ISharedRegionModule
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static bool m_Enabled = false;
47
48 private IConfigSource m_Config;
49 bool m_Registered = false;
50 HypergridServiceInConnector m_HypergridHandler;
51
52 #region IRegionModule interface
53
54 public void Initialise(IConfigSource config)
55 {
56 //// This module is only on for standalones in hypergrid mode
57 //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) &&
58 // config.Configs["Startup"].GetBoolean("hypergrid", true);
59 //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled);
60 m_Config = config;
61 IConfig moduleConfig = config.Configs["Modules"];
62 if (moduleConfig != null)
63 {
64 m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false);
65 if (m_Enabled)
66 {
67 m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled");
68 }
69
70 }
71
72 }
73
74 public void PostInitialise()
75 {
76 }
77
78 public void Close()
79 {
80 }
81
82 public Type ReplaceableInterface
83 {
84 get { return null; }
85 }
86
87 public string Name
88 {
89 get { return "HypergridService"; }
90 }
91
92 public void AddRegion(Scene scene)
93 {
94 if (!m_Enabled)
95 return;
96
97 if (!m_Registered)
98 {
99 m_Registered = true;
100
101 m_log.Info("[HypergridService]: Starting...");
102
103 Object[] args = new Object[] { m_Config, MainServer.Instance };
104
105 m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance);
106 //ServerUtils.LoadPlugin<HypergridServiceInConnector>("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args);
107 }
108
109 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
110 m_HypergridHandler.AddRegion(rinfo);
111 }
112
113 public void RemoveRegion(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo);
119 m_HypergridHandler.RemoveRegion(rinfo);
120 }
121
122 public void RegionLoaded(Scene scene)
123 {
124 }
125
126 #endregion
127
128 }
129}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
new file mode 100644
index 0000000..36915ef
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs
@@ -0,0 +1,303 @@
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.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35//using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class HGCommands
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 private HGGridConnector m_HGGridConnector;
48 private Scene m_scene;
49
50 private static uint m_autoMappingX = 0;
51 private static uint m_autoMappingY = 0;
52 private static bool m_enableAutoMapping = false;
53
54 public HGCommands(HGGridConnector hgConnector, Scene scene)
55 {
56 m_HGGridConnector = hgConnector;
57 m_scene = scene;
58 }
59
60 //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
61 // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
62 //{
63 // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
64
65 // return
66 // new HGScene(
67 // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
68 // m_moduleLoader, false, m_configSettings.PhysicalPrim,
69 // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
70 //}
71
72 public void RunCommand(string module, string[] cmdparams)
73 {
74 List<string> args = new List<string>(cmdparams);
75 if (args.Count < 1)
76 return;
77
78 string command = args[0];
79 args.RemoveAt(0);
80
81 cmdparams = args.ToArray();
82
83 RunHGCommand(command, cmdparams);
84
85 }
86
87 private void RunHGCommand(string command, string[] cmdparams)
88 {
89 if (command.Equals("linkk-mapping"))
90 {
91 if (cmdparams.Length == 2)
92 {
93 try
94 {
95 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
96 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
97 m_enableAutoMapping = true;
98 }
99 catch (Exception)
100 {
101 m_autoMappingX = 0;
102 m_autoMappingY = 0;
103 m_enableAutoMapping = false;
104 }
105 }
106 }
107 else if (command.Equals("linkk-region"))
108 {
109 if (cmdparams.Length < 3)
110 {
111 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
112 {
113 LoadXmlLinkFile(cmdparams);
114 }
115 else
116 {
117 LinkRegionCmdUsage();
118 }
119 return;
120 }
121
122 if (cmdparams[2].Contains(":"))
123 {
124 // New format
125 int xloc, yloc;
126 string mapName;
127 try
128 {
129 xloc = Convert.ToInt32(cmdparams[0]);
130 yloc = Convert.ToInt32(cmdparams[1]);
131 mapName = cmdparams[2];
132 if (cmdparams.Length > 3)
133 for (int i = 3; i < cmdparams.Length; i++)
134 mapName += " " + cmdparams[i];
135
136 m_log.Info(">> MapName: " + mapName);
137 //internalPort = Convert.ToUInt32(cmdparams[4]);
138 //remotingPort = Convert.ToUInt32(cmdparams[5]);
139 }
140 catch (Exception e)
141 {
142 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
143 LinkRegionCmdUsage();
144 return;
145 }
146
147 // Convert cell coordinates given by the user to meters
148 xloc = xloc * (int)Constants.RegionSize;
149 yloc = yloc * (int)Constants.RegionSize;
150 m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc);
151 }
152 else
153 {
154 // old format
155 GridRegion regInfo;
156 int xloc, yloc;
157 uint externalPort;
158 string externalHostName;
159 try
160 {
161 xloc = Convert.ToInt32(cmdparams[0]);
162 yloc = Convert.ToInt32(cmdparams[1]);
163 externalPort = Convert.ToUInt32(cmdparams[3]);
164 externalHostName = cmdparams[2];
165 //internalPort = Convert.ToUInt32(cmdparams[4]);
166 //remotingPort = Convert.ToUInt32(cmdparams[5]);
167 }
168 catch (Exception e)
169 {
170 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
171 LinkRegionCmdUsage();
172 return;
173 }
174
175 // Convert cell coordinates given by the user to meters
176 xloc = xloc * (int)Constants.RegionSize;
177 yloc = yloc * (int)Constants.RegionSize;
178 if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
179 {
180 if (cmdparams.Length >= 5)
181 {
182 regInfo.RegionName = "";
183 for (int i = 4; i < cmdparams.Length; i++)
184 regInfo.RegionName += cmdparams[i] + " ";
185 }
186 }
187 }
188 return;
189 }
190 else if (command.Equals("unlinkk-region"))
191 {
192 if (cmdparams.Length < 1)
193 {
194 UnlinkRegionCmdUsage();
195 return;
196 }
197 if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0]))
198 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
199 else
200 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
201 }
202 }
203
204 private void LoadXmlLinkFile(string[] cmdparams)
205 {
206 //use http://www.hgurl.com/hypergrid.xml for test
207 try
208 {
209 XmlReader r = XmlReader.Create(cmdparams[0]);
210 XmlConfigSource cs = new XmlConfigSource(r);
211 string[] excludeSections = null;
212
213 if (cmdparams.Length == 2)
214 {
215 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
216 {
217 string excludeString = cmdparams[1].ToLower();
218 excludeString = excludeString.Remove(0, 12);
219 char[] splitter = { ';' };
220
221 excludeSections = excludeString.Split(splitter);
222 }
223 }
224
225 for (int i = 0; i < cs.Configs.Count; i++)
226 {
227 bool skip = false;
228 if ((excludeSections != null) && (excludeSections.Length > 0))
229 {
230 for (int n = 0; n < excludeSections.Length; n++)
231 {
232 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
233 {
234 skip = true;
235 break;
236 }
237 }
238 }
239 if (!skip)
240 {
241 ReadLinkFromConfig(cs.Configs[i]);
242 }
243 }
244 }
245 catch (Exception e)
246 {
247 m_log.Error(e.ToString());
248 }
249 }
250
251
252 private void ReadLinkFromConfig(IConfig config)
253 {
254 GridRegion regInfo;
255 int xloc, yloc;
256 uint externalPort;
257 string externalHostName;
258 uint realXLoc, realYLoc;
259
260 xloc = Convert.ToInt32(config.GetString("xloc", "0"));
261 yloc = Convert.ToInt32(config.GetString("yloc", "0"));
262 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
263 externalHostName = config.GetString("externalHostName", "");
264 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
265 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
266
267 if (m_enableAutoMapping)
268 {
269 xloc = (int)((xloc % 100) + m_autoMappingX);
270 yloc = (int)((yloc % 100) + m_autoMappingY);
271 }
272
273 if (((realXLoc == 0) && (realYLoc == 0)) ||
274 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
275 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
276 {
277 xloc = xloc * (int)Constants.RegionSize;
278 yloc = yloc * (int)Constants.RegionSize;
279 if (
280 m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort,
281 externalHostName, out regInfo))
282 {
283 regInfo.RegionName = config.GetString("localName", "");
284 }
285 }
286 }
287
288
289 private void LinkRegionCmdUsage()
290 {
291 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
292 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
293 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
294 }
295
296 private void UnlinkRegionCmdUsage()
297 {
298 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
299 m_log.Info("Usage: unlink-region <LocalName>");
300 }
301
302 }
303}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
new file mode 100644
index 0000000..0c2a835
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -0,0 +1,560 @@
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.Net;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.Framework.Scenes.Hypergrid;
38using OpenSim.Services.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40using OpenSim.Server.Base;
41using OpenSim.Services.Connectors.Grid;
42using OpenSim.Framework.Console;
43
44using OpenMetaverse;
45using log4net;
46using Nini.Config;
47
48namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
49{
50 public class HGGridConnector : ISharedRegionModule, IGridService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private bool m_Enabled = false;
57 private bool m_Initialized = false;
58
59 private IGridService m_GridServiceConnector;
60 private HypergridServiceConnector m_HypergridServiceConnector;
61
62 // Hyperlink regions are hyperlinks on the map
63 protected Dictionary<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
64
65 // Known regions are home regions of visiting foreign users.
66 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
67 // the visitor goes away. They are mapped to X=0 on the map.
68 // This is key-ed on agent ID
69 protected Dictionary<UUID, GridRegion> m_knownRegions = new Dictionary<UUID, GridRegion>();
70
71 protected Dictionary<UUID, ulong> m_HyperlinkHandles = new Dictionary<UUID, ulong>();
72
73 #region ISharedRegionModule
74
75 public Type ReplaceableInterface
76 {
77 get { return null; }
78 }
79
80 public string Name
81 {
82 get { return "HGGridServicesConnector"; }
83 }
84
85 public void Initialise(IConfigSource source)
86 {
87 IConfig moduleConfig = source.Configs["Modules"];
88 if (moduleConfig != null)
89 {
90 string name = moduleConfig.GetString("GridServices", "");
91 if (name == Name)
92 {
93 IConfig gridConfig = source.Configs["GridService"];
94 if (gridConfig == null)
95 {
96 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100
101 InitialiseConnectorModule(source);
102
103 m_Enabled = true;
104 m_log.Info("[HGGRID CONNECTOR]: HG grid enabled");
105 }
106 }
107 }
108
109 private void InitialiseConnectorModule(IConfigSource source)
110 {
111 IConfig gridConfig = source.Configs["GridService"];
112 if (gridConfig == null)
113 {
114 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
115 throw new Exception("Grid connector init error");
116 }
117
118 string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty);
119 if (module == String.Empty)
120 {
121 m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService");
122 //return;
123 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
124 }
125
126 Object[] args = new Object[] { source };
127 m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args);
128
129 }
130
131 public void PostInitialise()
132 {
133 }
134
135 public void Close()
136 {
137 }
138
139 public void AddRegion(Scene scene)
140 {
141 if (!m_Enabled)
142 return;
143
144 scene.RegisterModuleInterface<IGridService>(this);
145
146 }
147
148 public void RemoveRegion(Scene scene)
149 {
150 }
151
152 public void RegionLoaded(Scene scene)
153 {
154 if (!m_Enabled)
155 return;
156
157 if (!m_Initialized)
158 {
159 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
160 HGCommands hgCommands = new HGCommands(this, scene);
161 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region",
162 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
163 "Link a hypergrid region", hgCommands.RunCommand);
164 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region",
165 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
166 "Unlink a hypergrid region", hgCommands.RunCommand);
167 MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [<x> <y>] <cr>",
168 "Set local coordinate to map HG regions to", hgCommands.RunCommand);
169 m_Initialized = true;
170 }
171
172
173 //scene.AddCommand("HGGridServicesConnector", "linkk-region",
174 // "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
175 // "Link a hypergrid region", hgCommands.RunCommand);
176 //scene.AddCommand("HGGridServicesConnector", "unlinkk-region",
177 // "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
178 // "Unlink a hypergrid region", hgCommands.RunCommand);
179 //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [<x> <y>] <cr>",
180 // "Set local coordinate to map HG regions to", hgCommands.RunCommand);
181
182 }
183
184 #endregion
185
186 #region IGridService
187
188 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
189 {
190 // Region doesn't exist here. Trying to link remote region
191 if (regionInfo.RegionID.Equals(UUID.Zero))
192 {
193 m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
194 ulong regionHandle = 0;
195 regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle);
196 if (!regionInfo.RegionID.Equals(UUID.Zero))
197 {
198 AddHyperlinkRegion(regionInfo, regionHandle);
199 m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
200
201 // Try get the map image
202 m_HypergridServiceConnector.GetMapImage(regionInfo);
203 return true;
204 }
205 else
206 {
207 m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
208 return false;
209 }
210 // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
211 }
212 else // normal grid
213 return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo);
214 }
215
216 public bool DeregisterRegion(UUID regionID)
217 {
218 // Try the hyperlink collection
219 if (m_HyperlinkRegions.ContainsKey(regionID))
220 {
221 RemoveHyperlinkRegion(regionID);
222 return true;
223 }
224 // Try the foreign users home collection
225
226 foreach (GridRegion r in m_knownRegions.Values)
227 if (r.RegionID == regionID)
228 {
229 RemoveHyperlinkHomeRegion(regionID);
230 return true;
231 }
232
233 // Finally, try the normal route
234 return m_GridServiceConnector.DeregisterRegion(regionID);
235 }
236
237 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
238 {
239 // No serving neighbours on hyperliked regions.
240 // Just the regular regions.
241 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
242 }
243
244 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
245 {
246 // Try the hyperlink collection
247 if (m_HyperlinkRegions.ContainsKey(regionID))
248 return m_HyperlinkRegions[regionID];
249
250 // Try the foreign users home collection
251 foreach (GridRegion r in m_knownRegions.Values)
252 if (r.RegionID == regionID)
253 return m_knownRegions[regionID];
254
255 // Finally, try the normal route
256 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
257 }
258
259 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
260 {
261 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
262 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
263 // Try the hyperlink collection
264 foreach (GridRegion r in m_HyperlinkRegions.Values)
265 {
266 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
267 return r;
268 }
269
270 // Try the foreign users home collection
271 foreach (GridRegion r in m_knownRegions.Values)
272 {
273 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
274 return r;
275 }
276
277 // Finally, try the normal route
278 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
279 }
280
281 public GridRegion GetRegionByName(UUID scopeID, string regionName)
282 {
283 // Try normal grid first
284 GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
285 if (region != null)
286 return region;
287
288 // Try the hyperlink collection
289 foreach (GridRegion r in m_HyperlinkRegions.Values)
290 {
291 if (r.RegionName == regionName)
292 return r;
293 }
294
295 // Try the foreign users home collection
296 foreach (GridRegion r in m_knownRegions.Values)
297 {
298 if (r.RegionName == regionName)
299 return r;
300 }
301 return null;
302 }
303
304 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
305 {
306 List<GridRegion> rinfos = new List<GridRegion>();
307
308 // Commenting until regionname exists
309 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
310 // if ((r.RegionName != null) && r.RegionName.StartsWith(name))
311 // rinfos.Add(r);
312
313 rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
314 return rinfos;
315 }
316
317 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
318 {
319 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
320 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
321 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
322 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
323
324 List<GridRegion> rinfos = new List<GridRegion>();
325 foreach (GridRegion r in m_HyperlinkRegions.Values)
326 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
327 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
328 rinfos.Add(r);
329
330 rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax));
331
332 return rinfos;
333 }
334
335 #endregion
336
337 #region Auxiliary
338
339 private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle)
340 {
341 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
342 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
343 }
344
345 private void RemoveHyperlinkRegion(UUID regionID)
346 {
347 m_HyperlinkRegions.Remove(regionID);
348 m_HyperlinkHandles.Remove(regionID);
349 }
350
351 private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle)
352 {
353 m_knownRegions.Add(userID, regionInfo);
354 m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle);
355 }
356
357 private void RemoveHyperlinkHomeRegion(UUID regionID)
358 {
359 foreach (KeyValuePair<UUID, GridRegion> kvp in m_knownRegions)
360 {
361 if (kvp.Value.RegionID == regionID)
362 {
363 m_knownRegions.Remove(kvp.Key);
364 }
365 }
366 m_HyperlinkHandles.Remove(regionID);
367 }
368 #endregion
369
370 #region Hyperlinks
371
372 private static Random random = new Random();
373
374 public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc)
375 {
376 string host = "127.0.0.1";
377 string portstr;
378 string regionName = "";
379 uint port = 9000;
380 string[] parts = mapName.Split(new char[] { ':' });
381 if (parts.Length >= 1)
382 {
383 host = parts[0];
384 }
385 if (parts.Length >= 2)
386 {
387 portstr = parts[1];
388 if (!UInt32.TryParse(portstr, out port))
389 regionName = parts[1];
390 }
391 // always take the last one
392 if (parts.Length >= 3)
393 {
394 regionName = parts[2];
395 }
396
397 // Sanity check. Don't ever link to this sim.
398 IPAddress ipaddr = null;
399 try
400 {
401 ipaddr = Util.GetHostFromDNS(host);
402 }
403 catch { }
404
405 if ((ipaddr != null) &&
406 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
407 {
408 GridRegion regInfo;
409 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
410 if (success)
411 {
412 regInfo.RegionName = mapName;
413 return regInfo;
414 }
415 }
416
417 return null;
418 }
419
420 // From the map search and secondlife://blah
421 public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
422 {
423 int xloc = random.Next(0, Int16.MaxValue);
424 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
425 }
426
427 public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc,
428 string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo)
429 {
430 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
431
432 regInfo = new GridRegion();
433 regInfo.RegionName = externalRegionName;
434 regInfo.HttpPort = externalPort;
435 regInfo.ExternalHostName = externalHostName;
436 regInfo.RegionLocX = xloc;
437 regInfo.RegionLocY = yloc;
438
439 try
440 {
441 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
442 }
443 catch (Exception e)
444 {
445 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
446 return false;
447 }
448
449 // Finally, link it
450 try
451 {
452 RegisterRegion(UUID.Zero, regInfo);
453 }
454 catch (Exception e)
455 {
456 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
457 return false;
458 }
459
460 int x, y;
461 if (!Check4096(m_scene, regInfo, out x, out y))
462 {
463 DeregisterRegion(regInfo.RegionID);
464 if (client != null)
465 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
466 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
467 return false;
468 }
469
470 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
471 {
472 DeregisterRegion(regInfo.RegionID);
473 if (client != null)
474 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
475 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
476 return false;
477 }
478
479 m_log.Debug("[HGrid]: link region succeeded");
480 return true;
481 }
482
483 public bool TryUnlinkRegion(Scene m_scene, string mapName)
484 {
485 GridRegion regInfo = null;
486 if (mapName.Contains(":"))
487 {
488 string host = "127.0.0.1";
489 //string portstr;
490 //string regionName = "";
491 uint port = 9000;
492 string[] parts = mapName.Split(new char[] { ':' });
493 if (parts.Length >= 1)
494 {
495 host = parts[0];
496 }
497 // if (parts.Length >= 2)
498 // {
499 // portstr = parts[1];
500 // if (!UInt32.TryParse(portstr, out port))
501 // regionName = parts[1];
502 // }
503 // always take the last one
504 // if (parts.Length >= 3)
505 // {
506 // regionName = parts[2];
507 // }
508 foreach (GridRegion r in m_HyperlinkRegions.Values)
509 if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
510 regInfo = r;
511 }
512 else
513 {
514 foreach (GridRegion r in m_HyperlinkRegions.Values)
515 if (r.RegionName.Equals(mapName))
516 regInfo = r;
517 }
518 if (regInfo != null)
519 {
520 return DeregisterRegion(regInfo.RegionID);
521 }
522 else
523 {
524 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
525 return false;
526 }
527 }
528
529 /// <summary>
530 /// Cope with this viewer limitation.
531 /// </summary>
532 /// <param name="regInfo"></param>
533 /// <returns></returns>
534 public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y)
535 {
536 ulong realHandle = m_HyperlinkHandles[regInfo.RegionID];
537 uint ux = 0, uy = 0;
538 Utils.LongToUInts(realHandle, out ux, out uy);
539 x = (int)(ux / Constants.RegionSize);
540 y = (int)(uy / Constants.RegionSize);
541
542 if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) ||
543 (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096))
544 {
545 return false;
546 }
547 return true;
548 }
549
550 public bool CheckCoords(uint thisx, uint thisy, int x, int y)
551 {
552 if ((thisx == x) && (thisy == y))
553 return false;
554 return true;
555 }
556
557 #endregion
558
559 }
560}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 6475817..743d3b9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -35,6 +35,7 @@ using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
@@ -50,6 +51,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
50 51
51 private bool m_Enabled = false; 52 private bool m_Enabled = false;
52 53
54 public LocalGridServicesConnector()
55 {
56 }
57
58 public LocalGridServicesConnector(IConfigSource source)
59 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
61 InitialiseService(source);
62 }
63
53 #region ISharedRegionModule 64 #region ISharedRegionModule
54 65
55 public Type ReplaceableInterface 66 public Type ReplaceableInterface
@@ -70,38 +81,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
70 string name = moduleConfig.GetString("GridServices", ""); 81 string name = moduleConfig.GetString("GridServices", "");
71 if (name == Name) 82 if (name == Name)
72 { 83 {
73 IConfig assetConfig = source.Configs["GridService"]; 84 InitialiseService(source);
74 if (assetConfig == null)
75 {
76 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
77 return;
78 }
79
80 string serviceDll = assetConfig.GetString("LocalServiceModule",
81 String.Empty);
82
83 if (serviceDll == String.Empty)
84 {
85 m_log.Error("[GRID CONNECTOR]: No LocalServiceModule named in section GridService");
86 return;
87 }
88
89 Object[] args = new Object[] { source };
90 m_GridService =
91 ServerUtils.LoadPlugin<IGridService>(serviceDll,
92 args);
93
94 if (m_GridService == null)
95 {
96 m_log.Error("[GRID CONNECTOR]: Can't load asset service");
97 return;
98 }
99 m_Enabled = true; 85 m_Enabled = true;
100 m_log.Info("[GRID CONNECTOR]: Local grid connector enabled"); 86 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
101 } 87 }
102 } 88 }
103 } 89 }
104 90
91 private void InitialiseService(IConfigSource source)
92 {
93 IConfig assetConfig = source.Configs["GridService"];
94 if (assetConfig == null)
95 {
96 m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100 string serviceDll = assetConfig.GetString("LocalServiceModule",
101 String.Empty);
102
103 if (serviceDll == String.Empty)
104 {
105 m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService");
106 return;
107 }
108
109 Object[] args = new Object[] { source };
110 m_GridService =
111 ServerUtils.LoadPlugin<IGridService>(serviceDll,
112 args);
113
114 if (m_GridService == null)
115 {
116 m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service");
117 return;
118 }
119 }
120
105 public void PostInitialise() 121 public void PostInitialise()
106 { 122 {
107 } 123 }
@@ -130,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
130 146
131 #region IGridService 147 #region IGridService
132 148
133 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) 149 public bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
134 { 150 {
135 return m_GridService.RegisterRegion(scopeID, regionInfo); 151 return m_GridService.RegisterRegion(scopeID, regionInfo);
136 } 152 }
@@ -140,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
140 return m_GridService.DeregisterRegion(regionID); 156 return m_GridService.DeregisterRegion(regionID);
141 } 157 }
142 158
143 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y) 159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
144 { 160 {
145 return m_GridService.GetNeighbours(scopeID, x, y); 161 return m_GridService.GetNeighbours(scopeID, regionID);
146 } 162 }
147 163
148 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
149 { 165 {
150 return m_GridService.GetRegionByUUID(scopeID, regionID); 166 return m_GridService.GetRegionByUUID(scopeID, regionID);
151 } 167 }
152 168
153 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 169 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
154 { 170 {
155 return m_GridService.GetRegionByPosition(scopeID, x, y); 171 return m_GridService.GetRegionByPosition(scopeID, x, y);
156 } 172 }
157 173
158 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 174 public GridRegion GetRegionByName(UUID scopeID, string regionName)
159 { 175 {
160 return m_GridService.GetRegionByName(scopeID, regionName); 176 return m_GridService.GetRegionByName(scopeID, regionName);
161 } 177 }
162 178
163 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 179 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
164 { 180 {
165 return m_GridService.GetRegionsByName(scopeID, name, maxNumber); 181 return m_GridService.GetRegionsByName(scopeID, name, maxNumber);
166 } 182 }
167 183
168 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 184 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
169 { 185 {
170 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); 186 return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
171 } 187 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
new file mode 100644
index 0000000..91a808b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -0,0 +1,183 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using Nini.Config;
33using OpenMetaverse;
34
35using OpenSim.Framework;
36using OpenSim.Services.Connectors;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
43{
44 public class RemoteGridServicesConnector :
45 GridServicesConnector, ISharedRegionModule, IGridService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private bool m_Enabled = false;
52
53 private IGridService m_LocalGridService;
54
55 public RemoteGridServicesConnector()
56 {
57 }
58
59 public RemoteGridServicesConnector(IConfigSource source)
60 {
61 InitialiseServices(source);
62 }
63
64 #region ISharedRegionmodule
65
66 public Type ReplaceableInterface
67 {
68 get { return null; }
69 }
70
71 public string Name
72 {
73 get { return "RemoteGridServicesConnector"; }
74 }
75
76 public override void Initialise(IConfigSource source)
77 {
78 IConfig moduleConfig = source.Configs["Modules"];
79 if (moduleConfig != null)
80 {
81 string name = moduleConfig.GetString("GridServices", "");
82 if (name == Name)
83 {
84 InitialiseServices(source);
85 m_Enabled = true;
86 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
87 }
88 }
89 }
90
91 private void InitialiseServices(IConfigSource source)
92 {
93 IConfig gridConfig = source.Configs["GridService"];
94 if (gridConfig == null)
95 {
96 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
97 return;
98 }
99
100 base.Initialise(source);
101
102 m_LocalGridService = new LocalGridServicesConnector(source);
103 }
104
105 public void PostInitialise()
106 {
107 }
108
109 public void Close()
110 {
111 }
112
113 public void AddRegion(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 scene.RegisterModuleInterface<IGridService>(this);
119 }
120
121 public void RemoveRegion(Scene scene)
122 {
123 }
124
125 public void RegionLoaded(Scene scene)
126 {
127 }
128
129 #endregion
130
131 #region IGridService
132
133 public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
134 {
135 if (m_LocalGridService.RegisterRegion(scopeID, regionInfo))
136 return base.RegisterRegion(scopeID, regionInfo);
137
138 return false;
139 }
140
141 public override bool DeregisterRegion(UUID regionID)
142 {
143 if (m_LocalGridService.DeregisterRegion(regionID))
144 return base.DeregisterRegion(regionID);
145
146 return false;
147 }
148
149 // Let's not override GetNeighbours -- let's get them all from the grid server
150
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 {
153 GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
154 if (rinfo == null)
155 rinfo = base.GetRegionByUUID(scopeID, regionID);
156
157 return rinfo;
158 }
159
160 public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
161 {
162 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
163 if (rinfo == null)
164 rinfo = base.GetRegionByPosition(scopeID, x, y);
165
166 return rinfo;
167 }
168
169 public override GridRegion GetRegionByName(UUID scopeID, string regionName)
170 {
171 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
172 if (rinfo == null)
173 rinfo = base.GetRegionByName(scopeID, regionName);
174
175 return rinfo;
176 }
177
178 // Let's not override GetRegionsByName -- let's get them all from the grid server
179 // Let's not override GetRegionRange -- let's get them all from the grid server
180
181 #endregion
182 }
183}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
new file mode 100644
index 0000000..be32d6b
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -0,0 +1,131 @@
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.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse;
37using OpenSim.Framework;
38using Nini.Config;
39
40using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
41using OpenSim.Region.Framework.Scenes;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Setup;
45
46namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
47{
48 [TestFixture]
49 public class GridConnectorsTests
50 {
51 LocalGridServicesConnector m_LocalConnector;
52 private void SetUp()
53 {
54 IConfigSource config = new IniConfigSource();
55 config.AddConfig("Modules");
56 config.AddConfig("GridService");
57 config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
58 config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
59 config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
60
61 m_LocalConnector = new LocalGridServicesConnector(config);
62 }
63
64 /// <summary>
65 /// Test saving a V0.2 OpenSim Region Archive.
66 /// </summary>
67 [Test]
68 public void TestRegisterRegionV0_2()
69 {
70 SetUp();
71
72 // Create 3 regions
73 GridRegion r1 = new GridRegion();
74 r1.RegionName = "Test Region 1";
75 r1.RegionID = new UUID(1);
76 r1.RegionLocX = 1000 * (int)Constants.RegionSize;
77 r1.RegionLocY = 1000 * (int)Constants.RegionSize;
78 r1.ExternalHostName = "127.0.0.1";
79 r1.HttpPort = 9001;
80 r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
81
82 GridRegion r2 = new GridRegion();
83 r2.RegionName = "Test Region 2";
84 r2.RegionID = new UUID(2);
85 r2.RegionLocX = 1001 * (int)Constants.RegionSize;
86 r2.RegionLocY = 1000 * (int)Constants.RegionSize;
87 r2.ExternalHostName = "127.0.0.1";
88 r2.HttpPort = 9002;
89 r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
90
91 GridRegion r3 = new GridRegion();
92 r3.RegionName = "Test Region 3";
93 r3.RegionID = new UUID(3);
94 r3.RegionLocX = 1005 * (int)Constants.RegionSize;
95 r3.RegionLocY = 1000 * (int)Constants.RegionSize;
96 r3.ExternalHostName = "127.0.0.1";
97 r3.HttpPort = 9003;
98 r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
99
100 m_LocalConnector.RegisterRegion(UUID.Zero, r1);
101 GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test");
102 Assert.IsNotNull(result, "Retrieved GetRegionByName is null");
103 Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match");
104
105 result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1));
106 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
107 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
108
109 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
110 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
111 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
112
113 m_LocalConnector.RegisterRegion(UUID.Zero, r2);
114 m_LocalConnector.RegisterRegion(UUID.Zero, r3);
115
116 List<GridRegion> results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1));
117 Assert.IsNotNull(results, "Retrieved neighbours list is null");
118 Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected");
119 Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match");
120
121 results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10);
122 Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null");
123 Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected");
124
125 results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize,
126 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
127 Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
128 Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
129 }
130 }
131}
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 75b3fe6..0d51cf4 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -33,7 +33,6 @@ using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.CoreModules.World.Terrain;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
39 38
@@ -47,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
47 46
48 private Scene m_scene; 47 private Scene m_scene;
49 48
50 private EstateTerrainXferHandler TerrainUploader = null; 49 private EstateTerrainXferHandler TerrainUploader;
51 50
52 #region Packet Data Responders 51 #region Packet Data Responders
53 52
@@ -155,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
155 break; 154 break;
156 } 155 }
157 m_scene.RegionInfo.RegionSettings.Save(); 156 m_scene.RegionInfo.RegionSettings.Save();
157 sendRegionInfoPacketToAll();
158 } 158 }
159 159
160 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) 160 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
@@ -179,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
179 break; 179 break;
180 } 180 }
181 m_scene.RegionInfo.RegionSettings.Save(); 181 m_scene.RegionInfo.RegionSettings.Save();
182 sendRegionInfoPacketToAll();
182 } 183 }
183 184
184 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) 185 private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
@@ -668,7 +669,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
668 LookupUUID(uuidNameLookupList); 669 LookupUUID(uuidNameLookupList);
669 } 670 }
670 671
671 private void LookupUUIDSCompleted(IAsyncResult iar) 672 private static void LookupUUIDSCompleted(IAsyncResult iar)
672 { 673 {
673 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState; 674 LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
674 icon.EndInvoke(iar); 675 icon.EndInvoke(iar);
@@ -683,7 +684,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
683 } 684 }
684 private void LookupUUIDsAsync(List<UUID> uuidLst) 685 private void LookupUUIDsAsync(List<UUID> uuidLst)
685 { 686 {
686 UUID[] uuidarr = new UUID[0]; 687 UUID[] uuidarr;
687 688
688 lock (uuidLst) 689 lock (uuidLst)
689 { 690 {
@@ -707,7 +708,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
707 708
708 for (int i = 0; i < avatars.Count; i++) 709 for (int i = 0; i < avatars.Count; i++)
709 { 710 {
710 HandleRegionInfoRequest(avatars[i].ControllingClient); ; 711 HandleRegionInfoRequest(avatars[i].ControllingClient);
711 } 712 }
712 } 713 }
713 714
@@ -768,7 +769,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
768 else 769 else
769 { 770 {
770 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; 771 m_scene.RegionInfo.EstateSettings.UseGlobalTime = false;
771 m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0; 772 m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
772 } 773 }
773 774
774 if ((parms1 & 0x00000010) != 0) 775 if ((parms1 & 0x00000010) != 0)
@@ -828,8 +829,60 @@ namespace OpenSim.Region.CoreModules.World.Estate
828 m_scene.RegisterModuleInterface<IEstateModule>(this); 829 m_scene.RegisterModuleInterface<IEstateModule>(this);
829 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 830 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
830 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; 831 m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
832
833 m_scene.AddCommand(this, "set terrain texture",
834 "set terrain texture <number> <uuid> [<x>] [<y>]",
835 "Sets the terrain <number> to <uuid>, if <x> or <y> are specified, it will only " +
836 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
837 " that coordinate.",
838 consoleSetTerrainTexture);
839
840 m_scene.AddCommand(this, "set terrain heights",
841 "set terrain heights <corner> <min> <max> [<x>] [<y>]",
842 "Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
843 "set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
844 " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
845 consoleSetTerrainHeights);
831 } 846 }
832 847
848 #region Console Commands
849
850 public void consoleSetTerrainTexture(string module, string[] args)
851 {
852 string num = args[3];
853 string uuid = args[4];
854 int x = (args.Length > 5 ? int.Parse(args[5]) : -1);
855 int y = (args.Length > 6 ? int.Parse(args[6]) : -1);
856
857 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
858 {
859 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
860 {
861 m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName);
862 setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid));
863 }
864 }
865 }
866
867 public void consoleSetTerrainHeights(string module, string[] args)
868 {
869 string num = args[3];
870 string min = args[4];
871 string max = args[5];
872 int x = (args.Length > 6 ? int.Parse(args[6]) : -1);
873 int y = (args.Length > 7 ? int.Parse(args[7]) : -1);
874
875 if (x == -1 || m_scene.RegionInfo.RegionLocX == x)
876 {
877 if (y == -1 || m_scene.RegionInfo.RegionLocY == y)
878 {
879 m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName);
880 setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max));
881 }
882 }
883 }
884
885 #endregion
833 886
834 public void PostInitialise() 887 public void PostInitialise()
835 { 888 {
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
index 1436912..181c5ae 100644
--- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
@@ -79,12 +79,12 @@ namespace OpenSim.Region.CoreModules.World.Land
79 { 79 {
80 if (!enabledYN) 80 if (!enabledYN)
81 return; 81 return;
82 82/*
83 // For testing on a single instance 83 // For testing on a single instance
84 if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000) 84 if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000)
85 return; 85 return;
86 // 86 //
87 87*/
88 lock (m_startingScenes) 88 lock (m_startingScenes)
89 m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); 89 m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
90 90
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 5d65f98..62efd60 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -47,8 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 // This maps between inventory server urls and inventory server clients 49 // This maps between inventory server urls and inventory server clients
50 private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 50// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
51
52 51
53 private Scene m_scene; 52 private Scene m_scene;
54 #endregion 53 #endregion
@@ -72,13 +71,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
72 return null; 71 return null;
73 } 72 }
74 73
75 private string UserInventoryURL(UUID userID) 74// private string UserInventoryURL(UUID userID)
76 { 75// {
77 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 76// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
78 if (uinfo != null) 77// if (uinfo != null)
79 return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; 78// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
80 return null; 79// return null;
81 } 80// }
82 81
83 private bool IsLocalUser(UUID userID) 82 private bool IsLocalUser(UUID userID)
84 { 83 {
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index 5c99d73..efc644d 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
77 if (regionHandle == m_regionInfo.RegionHandle) 77 if (regionHandle == m_regionInfo.RegionHandle)
78 { 78 {
79 // Teleport within the same region 79 // Teleport within the same region
80 if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0) 80 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
81 { 81 {
82 Vector3 emergencyPos = new Vector3(128, 128, 128); 82 Vector3 emergencyPos = new Vector3(128, 128, 128);
83 83
@@ -89,7 +89,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
89 // TODO: Get proper AVG Height 89 // TODO: Get proper AVG Height
90 float localAVHeight = 1.56f; 90 float localAVHeight = 1.56f;
91 91
92 float posZLimit = (float)avatar.Scene.Heightmap[(int)position.X, (int)position.Y]; 92 float posZLimit = 22;
93
94 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
95 {
96 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
97 }
98
93 float newPosZ = posZLimit + localAVHeight; 99 float newPosZ = posZLimit + localAVHeight;
94 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 100 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
95 { 101 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 204c319..5f2333e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -63,6 +63,13 @@ namespace OpenSim.Region.Framework.Scenes
63 63
64 protected List<UUID> m_agentsInTransit; 64 protected List<UUID> m_agentsInTransit;
65 65
66 public bool RegionLoginsEnabled
67 {
68 get { return m_regionLoginsEnabled; }
69 set { m_regionLoginsEnabled = value; }
70 }
71 private bool m_regionLoginsEnabled = false;
72
66 /// <summary> 73 /// <summary>
67 /// An agent is crossing into this region 74 /// An agent is crossing into this region
68 /// </summary> 75 /// </summary>
@@ -1163,7 +1170,7 @@ namespace OpenSim.Region.Framework.Scenes
1163 } 1170 }
1164 } 1171 }
1165 1172
1166 private bool IsOutsideRegion(Scene s, Vector3 pos) 1173 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1167 { 1174 {
1168 1175
1169 if (s.TestBorderCross(pos,Cardinals.N)) 1176 if (s.TestBorderCross(pos,Cardinals.N))
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4bd10bd..a260653 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -245,6 +245,11 @@ namespace OpenSim.Region.Framework.Scenes
245 } 245 }
246 } 246 }
247 247
248 private bool IsAttachmentCheckFull()
249 {
250 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0));
251 }
252
248 /// <summary> 253 /// <summary>
249 /// The absolute position of this scene object in the scene 254 /// The absolute position of this scene object in the scene
250 /// </summary> 255 /// </summary>
@@ -257,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
257 262
258 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 263 if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
259 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 264 || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
260 && !IsAttachment) 265 && !IsAttachmentCheckFull())
261 { 266 {
262 m_scene.CrossPrimGroupIntoNewRegion(val, this, true); 267 m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
263 } 268 }
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 7ab8b98..f22ea71 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
204 tempAngularVelocity2 = new btVector3(0, 0, 0); 204 tempAngularVelocity2 = new btVector3(0, 0, 0);
205 tempInertia1 = new btVector3(0, 0, 0); 205 tempInertia1 = new btVector3(0, 0, 0);
206 tempInertia2 = new btVector3(0, 0, 0); 206 tempInertia2 = new btVector3(0, 0, 0);
207 tempOrientation1 = new btQuaternion(0,0,0,1); 207 tempOrientation1 = new btQuaternion(0, 0, 0, 1);
208 tempOrientation2 = new btQuaternion(0, 0, 0, 1); 208 tempOrientation2 = new btQuaternion(0, 0, 0, 1);
209 _parent_scene = parent_scene; 209 _parent_scene = parent_scene;
210 tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); 210 tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero);
@@ -216,10 +216,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
216 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero); 216 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero);
217 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero); 217 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero);
218 218
219 219
220 AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize); 220 AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize);
221 int regionsize = (int) Constants.RegionSize; 221 int regionsize = (int)Constants.RegionSize;
222 222
223 if (regionsize == 256) 223 if (regionsize == 256)
224 regionsize = 512; 224 regionsize = 512;
225 225
@@ -611,7 +611,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
611 DisableAxisMotor(); 611 DisableAxisMotor();
612 DisposeOfBody(); 612 DisposeOfBody();
613 SetCollisionShape(null); 613 SetCollisionShape(null);
614 614
615 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero) 615 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero)
616 { 616 {
617 tempMotionState3.Dispose(); 617 tempMotionState3.Dispose();
@@ -677,8 +677,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
677 tempInertia2.Dispose(); 677 tempInertia2.Dispose();
678 tempInertia1 = null; 678 tempInertia1 = null;
679 } 679 }
680 680
681 681
682 if (tempAngularVelocity2 != null && tempAngularVelocity2.Handle != IntPtr.Zero) 682 if (tempAngularVelocity2 != null && tempAngularVelocity2.Handle != IntPtr.Zero)
683 { 683 {
684 tempAngularVelocity2.Dispose(); 684 tempAngularVelocity2.Dispose();
@@ -802,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
802 changesize(timestep); 802 changesize(timestep);
803 } 803 }
804 804
805 // 805 //
806 806
807 if (m_taintshape) 807 if (m_taintshape)
808 { 808 {
@@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1001 else 1001 else
1002 SetBody(0); 1002 SetBody(0);
1003 changeSelectedStatus(timestep); 1003 changeSelectedStatus(timestep);
1004 1004
1005 resetCollisionAccounting(); 1005 resetCollisionAccounting();
1006 m_taintPhysics = m_isphysical; 1006 m_taintPhysics = m_isphysical;
1007 } 1007 }
@@ -1012,7 +1012,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1012 { 1012 {
1013 if (_parent_scene.needsMeshing(_pbs)) 1013 if (_parent_scene.needsMeshing(_pbs))
1014 { 1014 {
1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero,Quaternion.Identity); 1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
1016 // createmesh returns null when it doesn't mesh. 1016 // createmesh returns null when it doesn't mesh.
1017 CreateGeom(IntPtr.Zero, _mesh); 1017 CreateGeom(IntPtr.Zero, _mesh);
1018 } 1018 }
@@ -1038,32 +1038,32 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1038 meshlod = _parent_scene.MeshSculptphysicalLOD; 1038 meshlod = _parent_scene.MeshSculptphysicalLOD;
1039 1039
1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero,0.001f) || orientation != Quaternion.Identity) 1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity)
1042 { 1042 {
1043 1043
1044 float[] xyz = new float[3]; 1044 float[] xyz = new float[3];
1045 xyz[0] = positionOffset.X; 1045 xyz[0] = positionOffset.X;
1046 xyz[1] = positionOffset.Y; 1046 xyz[1] = positionOffset.Y;
1047 xyz[2] = positionOffset.Z; 1047 xyz[2] = positionOffset.Z;
1048 1048
1049 Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation); 1049 Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation);
1050 1050
1051 float[,] matrix = new float[3,3]; 1051 float[,] matrix = new float[3, 3];
1052 1052
1053 matrix[0, 0] = m4.M11; 1053 matrix[0, 0] = m4.M11;
1054 matrix[0, 1] = m4.M12; 1054 matrix[0, 1] = m4.M12;
1055 matrix[0, 2] = m4.M13; 1055 matrix[0, 2] = m4.M13;
1056 matrix[1, 0] = m4.M21; 1056 matrix[1, 0] = m4.M21;
1057 matrix[1, 1] = m4.M22; 1057 matrix[1, 1] = m4.M22;
1058 matrix[1, 2] = m4.M23; 1058 matrix[1, 2] = m4.M23;
1059 matrix[2, 0] = m4.M31; 1059 matrix[2, 0] = m4.M31;
1060 matrix[2, 1] = m4.M32; 1060 matrix[2, 1] = m4.M32;
1061 matrix[2, 2] = m4.M33; 1061 matrix[2, 2] = m4.M33;
1062 1062
1063 1063
1064 mesh.TransformLinear(matrix, xyz); 1064 mesh.TransformLinear(matrix, xyz);
1065 1065
1066 1066
1067 1067
1068 } 1068 }
1069 1069
@@ -1088,12 +1088,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1088 SetCollisionShape(null); 1088 SetCollisionShape(null);
1089 // Construction of new prim 1089 // Construction of new prim
1090 ProcessGeomCreation(); 1090 ProcessGeomCreation();
1091 1091
1092 if (IsPhysical) 1092 if (IsPhysical)
1093 SetBody(Mass); 1093 SetBody(Mass);
1094 else 1094 else
1095 SetBody(0); 1095 SetBody(0);
1096 1096
1097 m_taintsize = _size; 1097 m_taintsize = _size;
1098 1098
1099 } 1099 }
@@ -1136,7 +1136,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1136 //prim_geom = IntPtr.Zero; 1136 //prim_geom = IntPtr.Zero;
1137 m_log.Error("[PHYSICS]: PrimGeom dead"); 1137 m_log.Error("[PHYSICS]: PrimGeom dead");
1138 } 1138 }
1139 1139
1140 // we don't need to do space calculation because the client sends a position update also. 1140 // we don't need to do space calculation because the client sends a position update also.
1141 if (_size.X <= 0) _size.X = 0.01f; 1141 if (_size.X <= 0) _size.X = 0.01f;
1142 if (_size.Y <= 0) _size.Y = 0.01f; 1142 if (_size.Y <= 0) _size.Y = 0.01f;
@@ -1153,8 +1153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1153 tempTransform1.Dispose(); 1153 tempTransform1.Dispose();
1154 tempTransform1 = new btTransform(tempOrientation1, tempPosition1); 1154 tempTransform1 = new btTransform(tempOrientation1, tempPosition1);
1155 1155
1156 1156
1157 1157
1158 1158
1159 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 1159 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1160 if (IsPhysical) 1160 if (IsPhysical)
@@ -1162,7 +1162,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1162 SetBody(Mass); 1162 SetBody(Mass);
1163 // Re creates body on size. 1163 // Re creates body on size.
1164 // EnableBody also does setMass() 1164 // EnableBody also does setMass()
1165 1165
1166 } 1166 }
1167 else 1167 else
1168 { 1168 {
@@ -1179,7 +1179,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1179 } 1179 }
1180 } 1180 }
1181 resetCollisionAccounting(); 1181 resetCollisionAccounting();
1182 1182
1183 m_taintshape = false; 1183 m_taintshape = false;
1184 } 1184 }
1185 1185
@@ -1291,7 +1291,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1291 { 1291 {
1292 Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE); 1292 Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE);
1293 disableBodySoft(); 1293 disableBodySoft();
1294 1294
1295 } 1295 }
1296 else 1296 else
1297 { 1297 {
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1299 enableBodySoft(); 1299 enableBodySoft();
1300 } 1300 }
1301 m_isSelected = m_taintselected; 1301 m_isSelected = m_taintselected;
1302 1302
1303 } 1303 }
1304 1304
1305 private void changevelocity(float timestep) 1305 private void changevelocity(float timestep)
@@ -1368,7 +1368,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1368 _parent = m_taintparent; 1368 _parent = m_taintparent;
1369 1369
1370 m_taintPhysics = m_isphysical; 1370 m_taintPhysics = m_isphysical;
1371 1371
1372 } 1372 }
1373 1373
1374 private void changefloatonwater(float timestep) 1374 private void changefloatonwater(float timestep)
@@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1627 { 1627 {
1628 if (m_zeroPosition == null) 1628 if (m_zeroPosition == null)
1629 m_zeroPosition = new PhysicsVector(0, 0, 0); 1629 m_zeroPosition = new PhysicsVector(0, 0, 0);
1630 m_zeroPosition.setValues(_position.X,_position.Y,_position.Z); 1630 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z);
1631 return; 1631 return;
1632 } 1632 }
1633 } 1633 }
@@ -1981,7 +1981,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1981 //_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); 1981 //_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical);
1982 _mesh = p_mesh; 1982 _mesh = p_mesh;
1983 setMesh(_parent_scene, _mesh); 1983 setMesh(_parent_scene, _mesh);
1984 1984
1985 } 1985 }
1986 else 1986 else
1987 { 1987 {
@@ -1994,15 +1994,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1994 //SetGeom to a Regular Sphere 1994 //SetGeom to a Regular Sphere
1995 if (tempSize1 == null) 1995 if (tempSize1 == null)
1996 tempSize1 = new btVector3(0, 0, 0); 1996 tempSize1 = new btVector3(0, 0, 0);
1997 tempSize1.setValue(_size.X * 0.5f,_size.Y * 0.5f, _size.Z * 0.5f); 1997 tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
1998 SetCollisionShape(new btSphereShape(_size.X*0.5f)); 1998 SetCollisionShape(new btSphereShape(_size.X * 0.5f));
1999 } 1999 }
2000 else 2000 else
2001 { 2001 {
2002 // uses halfextents 2002 // uses halfextents
2003 if (tempSize1 == null) 2003 if (tempSize1 == null)
2004 tempSize1 = new btVector3(0, 0, 0); 2004 tempSize1 = new btVector3(0, 0, 0);
2005 tempSize1.setValue(_size.X*0.5f, _size.Y*0.5f, _size.Z*0.5f); 2005 tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
2006 SetCollisionShape(new btBoxShape(tempSize1)); 2006 SetCollisionShape(new btBoxShape(tempSize1));
2007 } 2007 }
2008 } 2008 }
@@ -2052,14 +2052,24 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2052 } 2052 }
2053 } 2053 }
2054 2054
2055 //IMesh oldMesh = primMesh;
2056
2057 //primMesh = mesh;
2058
2059 //float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
2060 //int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
2061 ////Array.Reverse(indexList);
2062 //primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
2063
2055 IMesh oldMesh = primMesh; 2064 IMesh oldMesh = primMesh;
2056 2065
2057 primMesh = mesh; 2066 primMesh = mesh;
2058 2067
2059 float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory 2068 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
2060 int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage 2069 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
2061 //Array.Reverse(indexList); 2070 //Array.Reverse(indexList);
2062 primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory 2071 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
2072
2063 2073
2064 int VertexCount = vertexList.GetLength(0) / 3; 2074 int VertexCount = vertexList.GetLength(0) / 3;
2065 int IndexCount = indexList.GetLength(0); 2075 int IndexCount = indexList.GetLength(0);
@@ -2068,17 +2078,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2068 btshapeArray.Dispose(); 2078 btshapeArray.Dispose();
2069 //Array.Reverse(indexList); 2079 //Array.Reverse(indexList);
2070 btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)), 2080 btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)),
2071 VertexCount, vertexList, 3*sizeof (float)); 2081 VertexCount, vertexList, 3 * sizeof(float));
2072 SetCollisionShape(new btGImpactMeshShape(btshapeArray)); 2082 SetCollisionShape(new btGImpactMeshShape(btshapeArray));
2073 //((btGImpactMeshShape) prim_geom).updateBound(); 2083 //((btGImpactMeshShape) prim_geom).updateBound();
2074 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1,1, 1)); 2084 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
2075 ((btGImpactMeshShape)prim_geom).updateBound(); 2085 ((btGImpactMeshShape)prim_geom).updateBound();
2076 _parent_scene.SetUsingGImpact(); 2086 _parent_scene.SetUsingGImpact();
2077 if (oldMesh != null) 2087 //if (oldMesh != null)
2078 { 2088 //{
2079 oldMesh.releasePinned(); 2089 // oldMesh.releasePinned();
2080 oldMesh = null; 2090 // oldMesh = null;
2081 } 2091 //}
2082 2092
2083 } 2093 }
2084 2094
@@ -2102,7 +2112,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2102 } 2112 }
2103 */ 2113 */
2104 prim_geom = shape; 2114 prim_geom = shape;
2105 2115
2106 //Body.set 2116 //Body.set
2107 } 2117 }
2108 2118
@@ -2143,8 +2153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2143 2153
2144 if (prim_geom is btGImpactMeshShape) 2154 if (prim_geom is btGImpactMeshShape)
2145 { 2155 {
2146 ((btGImpactMeshShape) prim_geom).setLocalScaling(new btVector3(1, 1, 1)); 2156 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
2147 ((btGImpactMeshShape) prim_geom).updateBound(); 2157 ((btGImpactMeshShape)prim_geom).updateBound();
2148 } 2158 }
2149 //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK); 2159 //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK);
2150 //Body.setUserPointer((IntPtr) (int)m_localID); 2160 //Body.setUserPointer((IntPtr) (int)m_localID);
@@ -2159,7 +2169,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2159 { 2169 {
2160 if (chld == null) 2170 if (chld == null)
2161 continue; 2171 continue;
2162 2172
2163 // if (chld.NeedsMeshing()) 2173 // if (chld.NeedsMeshing())
2164 // hasTrimesh = true; 2174 // hasTrimesh = true;
2165 } 2175 }
@@ -2167,40 +2177,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2167 2177
2168 //if (hasTrimesh) 2178 //if (hasTrimesh)
2169 //{ 2179 //{
2170 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2180 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
2171 // createmesh returns null when it doesn't mesh. 2181 // createmesh returns null when it doesn't mesh.
2172
2173 /*
2174 if (_mesh is Mesh)
2175 {
2176 }
2177 else
2178 {
2179 m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
2180 return;
2181 }
2182 */
2183 2182
2184 2183 /*
2185 2184 if (_mesh is Mesh)
2186 foreach (BulletDotNETPrim chld in childrenPrim) 2185 {
2187 { 2186 }
2188 if (chld == null) 2187 else
2189 continue; 2188 {
2190 PhysicsVector offset = chld.Position - Position; 2189 m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
2191 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2190 return;
2192 pos *= Quaternion.Inverse(Orientation); 2191 }
2193 //pos *= Orientation; 2192 */
2194 offset.setValues(pos.X, pos.Y, pos.Z);
2195 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2196
2197 _mesh.Append(chld._mesh);
2198
2199 2193
2200 } 2194
2201 setMesh(_parent_scene, _mesh); 2195
2202 2196 foreach (BulletDotNETPrim chld in childrenPrim)
2203 //} 2197 {
2198 if (chld == null)
2199 continue;
2200 PhysicsVector offset = chld.Position - Position;
2201 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2202 pos *= Quaternion.Inverse(Orientation);
2203 //pos *= Orientation;
2204 offset.setValues(pos.X, pos.Y, pos.Z);
2205 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2206
2207 _mesh.Append(chld._mesh);
2208
2209
2210 }
2211 setMesh(_parent_scene, _mesh);
2212
2213 //}
2204 2214
2205 if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero) 2215 if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero)
2206 tempMotionState1.Dispose(); 2216 tempMotionState1.Dispose();
@@ -2238,7 +2248,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2238 ((btGImpactMeshShape)prim_geom).updateBound(); 2248 ((btGImpactMeshShape)prim_geom).updateBound();
2239 } 2249 }
2240 _parent_scene.AddPrimToScene(this); 2250 _parent_scene.AddPrimToScene(this);
2241 2251
2242 } 2252 }
2243 2253
2244 if (IsPhysical) 2254 if (IsPhysical)
@@ -2252,7 +2262,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2252 if (Body.Handle != IntPtr.Zero) 2262 if (Body.Handle != IntPtr.Zero)
2253 { 2263 {
2254 DisableAxisMotor(); 2264 DisableAxisMotor();
2255 _parent_scene.removeFromWorld(this,Body); 2265 _parent_scene.removeFromWorld(this, Body);
2256 Body.Dispose(); 2266 Body.Dispose();
2257 } 2267 }
2258 Body = null; 2268 Body = null;
@@ -2305,7 +2315,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2305 return; 2315 return;
2306 2316
2307 2317
2308 2318
2309 lock (childrenPrim) 2319 lock (childrenPrim)
2310 { 2320 {
2311 if (!childrenPrim.Contains(prm)) 2321 if (!childrenPrim.Contains(prm))
@@ -2313,8 +2323,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2313 childrenPrim.Add(prm); 2323 childrenPrim.Add(prm);
2314 } 2324 }
2315 } 2325 }
2316 2326
2317 2327
2318 } 2328 }
2319 2329
2320 public void disableBody() 2330 public void disableBody()
@@ -2386,7 +2396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2386 { 2396 {
2387 Body.clearForces(); 2397 Body.clearForces();
2388 Body.forceActivationState(0); 2398 Body.forceActivationState(0);
2389 2399
2390 } 2400 }
2391 2401
2392 } 2402 }
@@ -2400,7 +2410,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2400 Body.clearForces(); 2410 Body.clearForces();
2401 Body.forceActivationState(4); 2411 Body.forceActivationState(4);
2402 forceenable = true; 2412 forceenable = true;
2403 2413
2404 } 2414 }
2405 m_disabled = false; 2415 m_disabled = false;
2406 } 2416 }
@@ -2415,7 +2425,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2415 SetBody(Mass); 2425 SetBody(Mass);
2416 else 2426 else
2417 SetBody(0); 2427 SetBody(0);
2418 2428
2419 // TODO: Set Collision Category Bits and Flags 2429 // TODO: Set Collision Category Bits and Flags
2420 // TODO: Set Auto Disable data 2430 // TODO: Set Auto Disable data
2421 2431
@@ -2587,10 +2597,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2587 _velocity.Y = tempLinearVelocity1.getY(); 2597 _velocity.Y = tempLinearVelocity1.getY();
2588 _velocity.Z = tempLinearVelocity1.getZ(); 2598 _velocity.Z = tempLinearVelocity1.getZ();
2589 2599
2590 _acceleration = ((_velocity - m_lastVelocity)/0.1f); 2600 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2591 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X/0.1f, 2601 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f,
2592 _velocity.Y - m_lastVelocity.Y/0.1f, 2602 _velocity.Y - m_lastVelocity.Y / 0.1f,
2593 _velocity.Z - m_lastVelocity.Z/0.1f); 2603 _velocity.Z - m_lastVelocity.Z / 0.1f);
2594 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2604 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2595 2605
2596 if (_velocity.IsIdentical(pv, 0.5f)) 2606 if (_velocity.IsIdentical(pv, 0.5f))
@@ -2669,7 +2679,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2669 if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero) 2679 if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero)
2670 AxisLockAngleHigh.Dispose(); 2680 AxisLockAngleHigh.Dispose();
2671 2681
2672 2682
2673 2683
2674 m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero, 2684 m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero,
2675 _parent_scene.TransZero, false); 2685 _parent_scene.TransZero, false);
@@ -2683,7 +2693,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2683 m_aMotor.setLinearUpperLimit(AxisLockLinearHigh); 2693 m_aMotor.setLinearUpperLimit(AxisLockLinearHigh);
2684 _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor); 2694 _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor);
2685 //m_aMotor. 2695 //m_aMotor.
2686 2696
2687 2697
2688 } 2698 }
2689 internal void DisableAxisMotor() 2699 internal void DisableAxisMotor()
@@ -2698,4 +2708,4 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2698 2708
2699 } 2709 }
2700} 2710}
2701 2711
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index ceafaad..7567556 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Region.Physics.Meshing
40 private List<Triangle> triangles; 40 private List<Triangle> triangles;
41 GCHandle pinnedVirtexes; 41 GCHandle pinnedVirtexes;
42 GCHandle pinnedIndex; 42 GCHandle pinnedIndex;
43 public PrimMesh primMesh = null;
44 public float[] normals; 43 public float[] normals;
45 44
46 public Mesh() 45 public Mesh()
@@ -63,6 +62,8 @@ namespace OpenSim.Region.Physics.Meshing
63 62
64 public void Add(Triangle triangle) 63 public void Add(Triangle triangle)
65 { 64 {
65 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
66 throw new NotSupportedException("Attempt to Add to a pinned Mesh");
66 // If a vertex of the triangle is not yet in the vertices list, 67 // If a vertex of the triangle is not yet in the vertices list,
67 // add it and set its index to the current index count 68 // add it and set its index to the current index count
68 if (!vertices.ContainsKey(triangle.v1)) 69 if (!vertices.ContainsKey(triangle.v1))
@@ -148,40 +149,22 @@ namespace OpenSim.Region.Physics.Meshing
148 149
149 public float[] getVertexListAsFloatLocked() 150 public float[] getVertexListAsFloatLocked()
150 { 151 {
152 if( pinnedVirtexes.IsAllocated )
153 return (float[])(pinnedVirtexes.Target);
151 float[] result; 154 float[] result;
152 155
153 if (primMesh == null) 156 //m_log.WarnFormat("vertices.Count = {0}", vertices.Count);
157 result = new float[vertices.Count * 3];
158 foreach (KeyValuePair<Vertex, int> kvp in vertices)
154 { 159 {
155 //m_log.WarnFormat("vertices.Count = {0}", vertices.Count); 160 Vertex v = kvp.Key;
156 result = new float[vertices.Count * 3]; 161 int i = kvp.Value;
157 foreach (KeyValuePair<Vertex, int> kvp in vertices) 162 //m_log.WarnFormat("kvp.Value = {0}", i);
158 { 163 result[3 * i + 0] = v.X;
159 Vertex v = kvp.Key; 164 result[3 * i + 1] = v.Y;
160 int i = kvp.Value; 165 result[3 * i + 2] = v.Z;
161 //m_log.WarnFormat("kvp.Value = {0}", i);
162 result[3 * i + 0] = v.X;
163 result[3 * i + 1] = v.Y;
164 result[3 * i + 2] = v.Z;
165 }
166 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
167 }
168 else
169 {
170 int count = primMesh.coords.Count;
171 result = new float[count * 3];
172 for (int i = 0; i < count; i++)
173 {
174 Coord c = primMesh.coords[i];
175 {
176 int resultIndex = 3 * i;
177 result[resultIndex] = c.X;
178 result[resultIndex + 1] = c.Y;
179 result[resultIndex + 2] = c.Z;
180 }
181
182 }
183 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
184 } 166 }
167 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
185 return result; 168 return result;
186 } 169 }
187 170
@@ -189,33 +172,13 @@ namespace OpenSim.Region.Physics.Meshing
189 { 172 {
190 int[] result; 173 int[] result;
191 174
192 if (primMesh == null) 175 result = new int[triangles.Count * 3];
193 { 176 for (int i = 0; i < triangles.Count; i++)
194 result = new int[triangles.Count * 3];
195 for (int i = 0; i < triangles.Count; i++)
196 {
197 Triangle t = triangles[i];
198 result[3 * i + 0] = vertices[t.v1];
199 result[3 * i + 1] = vertices[t.v2];
200 result[3 * i + 2] = vertices[t.v3];
201 }
202 }
203 else
204 { 177 {
205 int numFaces = primMesh.faces.Count; 178 Triangle t = triangles[i];
206 result = new int[numFaces * 3]; 179 result[3 * i + 0] = vertices[t.v1];
207 for (int i = 0; i < numFaces; i++) 180 result[3 * i + 1] = vertices[t.v2];
208 { 181 result[3 * i + 2] = vertices[t.v3];
209 Face f = primMesh.faces[i];
210// Coord c1 = primMesh.coords[f.v1];
211// Coord c2 = primMesh.coords[f.v2];
212// Coord c3 = primMesh.coords[f.v3];
213
214 int resultIndex = i * 3;
215 result[resultIndex] = f.v1;
216 result[resultIndex + 1] = f.v2;
217 result[resultIndex + 2] = f.v3;
218 }
219 } 182 }
220 return result; 183 return result;
221 } 184 }
@@ -226,6 +189,9 @@ namespace OpenSim.Region.Physics.Meshing
226 /// <returns></returns> 189 /// <returns></returns>
227 public int[] getIndexListAsIntLocked() 190 public int[] getIndexListAsIntLocked()
228 { 191 {
192 if (pinnedIndex.IsAllocated)
193 return (int[])(pinnedIndex.Target);
194
229 int[] result = getIndexListAsInt(); 195 int[] result = getIndexListAsInt();
230 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); 196 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
231 197
@@ -245,11 +211,13 @@ namespace OpenSim.Region.Physics.Meshing
245 { 211 {
246 triangles = null; 212 triangles = null;
247 vertices = null; 213 vertices = null;
248 primMesh = null;
249 } 214 }
250 215
251 public void Append(IMesh newMesh) 216 public void Append(IMesh newMesh)
252 { 217 {
218 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
219 throw new NotSupportedException("Attempt to Append to a pinned Mesh");
220
253 if (!(newMesh is Mesh)) 221 if (!(newMesh is Mesh))
254 return; 222 return;
255 223
@@ -260,6 +228,9 @@ namespace OpenSim.Region.Physics.Meshing
260 // Do a linear transformation of mesh. 228 // Do a linear transformation of mesh.
261 public void TransformLinear(float[,] matrix, float[] offset) 229 public void TransformLinear(float[,] matrix, float[] offset)
262 { 230 {
231 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
232 throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh");
233
263 foreach (Vertex v in vertices.Keys) 234 foreach (Vertex v in vertices.Keys)
264 { 235 {
265 if (v == null) 236 if (v == null)
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index f469ad6..0873035 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -76,6 +76,7 @@ namespace OpenSim.Region.Physics.Meshing
76 76
77 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh 77 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
78 78
79 private Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>();
79 80
80 /// <summary> 81 /// <summary>
81 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may 82 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
@@ -170,9 +171,62 @@ namespace OpenSim.Region.Physics.Meshing
170 171
171 } 172 }
172 173
173 public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 174 private ulong GetMeshKey( PrimitiveBaseShape pbs, PhysicsVector size, float lod )
175 {
176 ulong hash = 5381;
177
178 hash = djb2(hash, pbs.PathCurve);
179 hash = djb2(hash, (byte)((byte)pbs.HollowShape | (byte)pbs.ProfileShape));
180 hash = djb2(hash, pbs.PathBegin);
181 hash = djb2(hash, pbs.PathEnd);
182 hash = djb2(hash, pbs.PathScaleX);
183 hash = djb2(hash, pbs.PathScaleY);
184 hash = djb2(hash, pbs.PathShearX);
185 hash = djb2(hash, pbs.PathShearY);
186 hash = djb2(hash, (byte)pbs.PathTwist);
187 hash = djb2(hash, (byte)pbs.PathTwistBegin);
188 hash = djb2(hash, (byte)pbs.PathRadiusOffset);
189 hash = djb2(hash, (byte)pbs.PathTaperX);
190 hash = djb2(hash, (byte)pbs.PathTaperY);
191 hash = djb2(hash, pbs.PathRevolutions);
192 hash = djb2(hash, (byte)pbs.PathSkew);
193 hash = djb2(hash, pbs.ProfileBegin);
194 hash = djb2(hash, pbs.ProfileEnd);
195 hash = djb2(hash, pbs.ProfileHollow);
196
197 // TODO: Separate scale out from the primitive shape data (after
198 // scaling is supported at the physics engine level)
199 byte[] scaleBytes = size.GetBytes();
200 for (int i = 0; i < scaleBytes.Length; i++)
201 hash = djb2(hash, scaleBytes[i]);
202
203 // Include LOD in hash, accounting for endianness
204 byte[] lodBytes = new byte[4];
205 Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
206 if (!BitConverter.IsLittleEndian)
207 {
208 Array.Reverse(lodBytes, 0, 4);
209 }
210 for (int i = 0; i < lodBytes.Length; i++)
211 hash = djb2(hash, lodBytes[i]);
212
213 return hash;
214 }
215
216 private ulong djb2(ulong hash, byte c)
217 {
218 return ((hash << 5) + hash) + (ulong)c;
219 }
220
221 private ulong djb2(ulong hash, ushort c)
222 {
223 hash = ((hash << 5) + hash) + (ulong)((byte)c);
224 return ((hash << 5) + hash) + (ulong)(c >> 8);
225 }
226
227
228 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod)
174 { 229 {
175 Mesh mesh = new Mesh();
176 PrimMesh primMesh; 230 PrimMesh primMesh;
177 PrimMesher.SculptMesh sculptMesh; 231 PrimMesher.SculptMesh sculptMesh;
178 232
@@ -385,8 +439,6 @@ namespace OpenSim.Region.Physics.Meshing
385 439
386 coords = primMesh.coords; 440 coords = primMesh.coords;
387 faces = primMesh.faces; 441 faces = primMesh.faces;
388
389
390 } 442 }
391 443
392 444
@@ -401,13 +453,13 @@ namespace OpenSim.Region.Physics.Meshing
401 vertices.Add(new Vertex(c.X, c.Y, c.Z)); 453 vertices.Add(new Vertex(c.X, c.Y, c.Z));
402 } 454 }
403 455
456 Mesh mesh = new Mesh();
404 // Add the corresponding triangles to the mesh 457 // Add the corresponding triangles to the mesh
405 for (int i = 0; i < numFaces; i++) 458 for (int i = 0; i < numFaces; i++)
406 { 459 {
407 Face f = faces[i]; 460 Face f = faces[i];
408 mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); 461 mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3]));
409 } 462 }
410
411 return mesh; 463 return mesh;
412 } 464 }
413 465
@@ -418,7 +470,12 @@ namespace OpenSim.Region.Physics.Meshing
418 470
419 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) 471 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical)
420 { 472 {
473 // If this mesh has been created already, return it instead of creating another copy
474 // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
475 ulong key = GetMeshKey(primShape, size, lod);
421 Mesh mesh = null; 476 Mesh mesh = null;
477 if (m_uniqueMeshes.TryGetValue(key, out mesh))
478 return mesh;
422 479
423 if (size.X < 0.01f) size.X = 0.01f; 480 if (size.X < 0.01f) size.X = 0.01f;
424 if (size.Y < 0.01f) size.Y = 0.01f; 481 if (size.Y < 0.01f) size.Y = 0.01f;
@@ -441,7 +498,7 @@ namespace OpenSim.Region.Physics.Meshing
441 // trim the vertex and triangle lists to free up memory 498 // trim the vertex and triangle lists to free up memory
442 mesh.TrimExcess(); 499 mesh.TrimExcess();
443 } 500 }
444 501 m_uniqueMeshes.Add(key, mesh);
445 return mesh; 502 return mesh;
446 } 503 }
447 } 504 }
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index 0d19c01..abfd400 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -345,6 +345,21 @@ namespace PrimMesher
345 this.v3.Z *= z; 345 this.v3.Z *= z;
346 } 346 }
347 347
348 public void AddPos(float x, float y, float z)
349 {
350 this.v1.X += x;
351 this.v2.X += x;
352 this.v3.X += x;
353
354 this.v1.Y += y;
355 this.v2.Y += y;
356 this.v3.Y += y;
357
358 this.v1.Z += z;
359 this.v2.Z += z;
360 this.v3.Z += z;
361 }
362
348 public void AddRot(Quat q) 363 public void AddRot(Quat q)
349 { 364 {
350 this.v1 *= q; 365 this.v1 *= q;
@@ -2141,6 +2156,18 @@ namespace PrimMesher
2141 vert.Z += z; 2156 vert.Z += z;
2142 this.coords[i] = vert; 2157 this.coords[i] = vert;
2143 } 2158 }
2159
2160 if (this.viewerFaces != null)
2161 {
2162 int numViewerFaces = this.viewerFaces.Count;
2163
2164 for (i = 0; i < numViewerFaces; i++)
2165 {
2166 ViewerFace v = this.viewerFaces[i];
2167 v.AddPos(x, y, z);
2168 this.viewerFaces[i] = v;
2169 }
2170 }
2144 } 2171 }
2145 2172
2146 /// <summary> 2173 /// <summary>
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
index bf42fee..bd63aef 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
@@ -494,6 +494,18 @@ namespace PrimMesher
494 vert.Z += z; 494 vert.Z += z;
495 this.coords[i] = vert; 495 this.coords[i] = vert;
496 } 496 }
497
498 if (this.viewerFaces != null)
499 {
500 int numViewerFaces = this.viewerFaces.Count;
501
502 for (i = 0; i < numViewerFaces; i++)
503 {
504 ViewerFace v = this.viewerFaces[i];
505 v.AddPos(x, y, z);
506 this.viewerFaces[i] = v;
507 }
508 }
497 } 509 }
498 510
499 /// <summary> 511 /// <summary>
@@ -556,7 +568,7 @@ namespace PrimMesher
556 if (path == null) 568 if (path == null)
557 return; 569 return;
558 String fileName = name + "_" + title + ".raw"; 570 String fileName = name + "_" + title + ".raw";
559 String completePath = Path.Combine(path, fileName); 571 String completePath = System.IO.Path.Combine(path, fileName);
560 StreamWriter sw = new StreamWriter(completePath); 572 StreamWriter sw = new StreamWriter(completePath);
561 573
562 for (int i = 0; i < this.faces.Count; i++) 574 for (int i = 0; i < this.faces.Count; i++)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 34844c0..86ed3bd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -97,7 +97,6 @@ namespace OpenSim.Region.Physics.OdePlugin
97 97
98 // private float m_tensor = 5f; 98 // private float m_tensor = 5f;
99 private int body_autodisable_frames = 20; 99 private int body_autodisable_frames = 20;
100 private IMesh primMesh = null;
101 100
102 101
103 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 102 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
@@ -825,14 +824,10 @@ namespace OpenSim.Region.Physics.OdePlugin
825 } 824 }
826 } 825 }
827 826
828 IMesh oldMesh = primMesh; 827 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
828 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
829 829
830 primMesh = mesh; 830 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
831
832 float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
833 int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
834
835 primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
836 831
837 int VertexCount = vertexList.GetLength(0)/3; 832 int VertexCount = vertexList.GetLength(0)/3;
838 int IndexCount = indexList.GetLength(0); 833 int IndexCount = indexList.GetLength(0);
@@ -859,12 +854,6 @@ namespace OpenSim.Region.Physics.OdePlugin
859 return; 854 return;
860 } 855 }
861 856
862 if (oldMesh != null)
863 {
864 oldMesh.releasePinned();
865 oldMesh = null;
866 }
867
868 // if (IsPhysical && Body == (IntPtr) 0) 857 // if (IsPhysical && Body == (IntPtr) 0)
869 // { 858 // {
870 // Recreate the body 859 // Recreate the body
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index edcf11c..c41f2a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -24,7 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
@@ -7841,8 +7841,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7841 public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) 7841 public LSL_String llGetHTTPHeader(LSL_Key request_id, string header)
7842 { 7842 {
7843 m_host.AddScriptLPS(1); 7843 m_host.AddScriptLPS(1);
7844 NotImplemented("llGetHTTPHeader"); 7844
7845 return String.Empty; 7845 if (m_UrlModule != null)
7846 return m_UrlModule.GetHttpHeader(new UUID(request_id), header);
7847 return String.Empty;
7846 } 7848 }
7847 7849
7848 7850
@@ -9120,13 +9122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9120 } 9122 }
9121 9123
9122 9124
9123 public void llHTTPResponse(string url, int status, string body) 9125 public void llHTTPResponse(LSL_Key id, int status, string body)
9124 { 9126 {
9125 // Partial implementation: support for parameter flags needed 9127 // Partial implementation: support for parameter flags needed
9126 // see http://wiki.secondlife.com/wiki/llHTTPResponse 9128 // see http://wiki.secondlife.com/wiki/llHTTPResponse
9127 9129
9128 m_host.AddScriptLPS(1); 9130 m_host.AddScriptLPS(1);
9129 NotImplemented("llHTTPResponse"); 9131
9132 if (m_UrlModule != null)
9133 m_UrlModule.HttpResponse(new UUID(id), status,body);
9130 } 9134 }
9131 9135
9132 public void llResetLandBanList() 9136 public void llResetLandBanList()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 41358e5..a74e8da 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -201,7 +201,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
201 void llGroundRepel(double height, int water, double tau); 201 void llGroundRepel(double height, int water, double tau);
202 LSL_Vector llGroundSlope(LSL_Vector offset); 202 LSL_Vector llGroundSlope(LSL_Vector offset);
203 LSL_String llHTTPRequest(string url, LSL_List parameters, string body); 203 LSL_String llHTTPRequest(string url, LSL_List parameters, string body);
204 void llHTTPResponse(string url, int status, string body); 204 void llHTTPResponse(LSL_Key id, int status, string body);
205 LSL_String llInsertString(string dst, int position, string src); 205 LSL_String llInsertString(string dst, int position, string src);
206 void llInstantMessage(string user, string message); 206 void llInstantMessage(string user, string message);
207 LSL_String llIntegerToBase64(int number); 207 LSL_String llIntegerToBase64(int number);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 02ae281..a28e97b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -864,9 +864,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
864 return m_LSL_Functions.llHTTPRequest(url, parameters, body); 864 return m_LSL_Functions.llHTTPRequest(url, parameters, body);
865 } 865 }
866 866
867 public void llHTTPResponse(string url, int status, string body) 867 public void llHTTPResponse(LSL_Key id, int status, string body)
868 { 868 {
869 m_LSL_Functions.llHTTPResponse(url, status, body); 869 m_LSL_Functions.llHTTPResponse(id, status, body);
870 } 870 }
871 871
872 public LSL_String llInsertString(string dst, int position, string src) 872 public LSL_String llInsertString(string dst, int position, string src)
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index cb5664b..5a94957 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -542,11 +542,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
542 break; 542 break;
543 case enumCompileType.cs: 543 case enumCompileType.cs:
544 case enumCompileType.lsl: 544 case enumCompileType.lsl:
545 lock (CScodeProvider) 545 bool complete = false;
546 bool retried = false;
547 do
546 { 548 {
547 results = CScodeProvider.CompileAssemblyFromSource( 549 lock (CScodeProvider)
548 parameters, Script); 550 {
551 results = CScodeProvider.CompileAssemblyFromSource(
552 parameters, Script);
553 }
554 // Deal with an occasional segv in the compiler.
555 // Rarely, if ever, occurs twice in succession.
556 // Line # == 0 and no file name are indications that
557 // this is a native stack trace rather than a normal
558 // error log.
559 if (results.Errors.Count > 0)
560 {
561 if (!retried && (results.Errors[0].FileName == null || results.Errors[0].FileName == String.Empty) &&
562 results.Errors[0].Line == 0)
563 {
564 // System.Console.WriteLine("retrying failed compilation");
565 retried = true;
566 }
567 else
568 {
569 complete = true;
570 }
571 }
572 else
573 {
574 complete = true;
575 }
549 } 576 }
577 while(!complete);
550 break; 578 break;
551 case enumCompileType.js: 579 case enumCompileType.js:
552 results = JScodeProvider.CompileAssemblyFromSource( 580 results = JScodeProvider.CompileAssemblyFromSource(
@@ -567,17 +595,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
567 // 595 //
568 // WARNINGS AND ERRORS 596 // WARNINGS AND ERRORS
569 // 597 //
570 int display = 5; 598 bool hadErrors = false;
599 string errtext = String.Empty;
600
571 if (results.Errors.Count > 0) 601 if (results.Errors.Count > 0)
572 { 602 {
573 string errtext = String.Empty;
574 foreach (CompilerError CompErr in results.Errors) 603 foreach (CompilerError CompErr in results.Errors)
575 { 604 {
576 // Show 5 errors max
577 //
578 if (display <= 0)
579 break;
580 display--;
581 605
582 string severity = "Error"; 606 string severity = "Error";
583 if (CompErr.IsWarning) 607 if (CompErr.IsWarning)
@@ -587,36 +611,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
587 611
588 KeyValuePair<int, int> lslPos; 612 KeyValuePair<int, int> lslPos;
589 613
590 lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); 614 // Show 5 errors max, but check entire list for errors
615
616 if (severity == "Error")
617 {
618 lslPos = FindErrorPosition(CompErr.Line, CompErr.Column);
619 string text = CompErr.ErrorText;
620
621 // Use LSL type names
622 if (lang == enumCompileType.lsl)
623 text = ReplaceTypes(CompErr.ErrorText);
624
625 // The Second Life viewer's script editor begins
626 // countingn lines and columns at 0, so we subtract 1.
627 errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n",
628 lslPos.Key - 1, lslPos.Value - 1,
629 CompErr.ErrorNumber, text, severity);
630 hadErrors = true;
631 }
632 }
633 }
591 634
592 string text = CompErr.ErrorText; 635 if (hadErrors)
636 {
637 throw new Exception(errtext);
638 }
593 639
594 // Use LSL type names 640 // On today's highly asynchronous systems, the result of
595 if (lang == enumCompileType.lsl) 641 // the compile may not be immediately apparent. Wait a
596 text = ReplaceTypes(CompErr.ErrorText); 642 // reasonable amount of time before giving up on it.
597 643
598 // The Second Life viewer's script editor begins 644 if (!File.Exists(OutFile))
599 // countingn lines and columns at 0, so we subtract 1. 645 {
600 errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", 646 for (int i=0; i<20 && !File.Exists(OutFile); i++)
601 lslPos.Key - 1, lslPos.Value - 1, 647 {
602 CompErr.ErrorNumber, text, severity); 648 System.Threading.Thread.Sleep(250);
603 } 649 }
604 650 // One final chance...
605 if (!File.Exists(OutFile)) 651 if (!File.Exists(OutFile))
606 { 652 {
653 errtext = String.Empty;
654 errtext += "No compile error. But not able to locate compiled file.";
607 throw new Exception(errtext); 655 throw new Exception(errtext);
608 } 656 }
609 } 657 }
610 658
611 //
612 // NO ERRORS, BUT NO COMPILED FILE
613 //
614 if (!File.Exists(OutFile))
615 {
616 string errtext = String.Empty;
617 errtext += "No compile error. But not able to locate compiled file.";
618 throw new Exception(errtext);
619 }
620// m_log.DebugFormat("[Compiler] Compiled new assembly "+ 659// m_log.DebugFormat("[Compiler] Compiled new assembly "+
621// "for {0}", asset); 660// "for {0}", asset);
622 661
@@ -629,7 +668,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
629 668
630 if (fi == null) 669 if (fi == null)
631 { 670 {
632 string errtext = String.Empty; 671 errtext = String.Empty;
633 errtext += "No compile error. But not able to stat file."; 672 errtext += "No compile error. But not able to stat file.";
634 throw new Exception(errtext); 673 throw new Exception(errtext);
635 } 674 }
@@ -644,7 +683,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
644 } 683 }
645 catch (Exception) 684 catch (Exception)
646 { 685 {
647 string errtext = String.Empty; 686 errtext = String.Empty;
648 errtext += "No compile error. But not able to open file."; 687 errtext += "No compile error. But not able to open file.";
649 throw new Exception(errtext); 688 throw new Exception(errtext);
650 } 689 }
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 791e1ef..ed0210f 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Threading; 30using System.Threading;
30using System.Reflection; 31using System.Reflection;
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -40,17 +41,40 @@ namespace OpenSim.Server.Base
40 { 41 {
41 // Logger 42 // Logger
42 // 43 //
43 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 // The http server instance 46 // The http server instance
46 // 47 //
47 protected BaseHttpServer m_HttpServer = null; 48 protected BaseHttpServer m_HttpServer = null;
49 protected uint m_Port = 0;
50 protected Dictionary<uint, BaseHttpServer> m_Servers =
51 new Dictionary<uint, BaseHttpServer>();
48 52
49 public IHttpServer HttpServer 53 public IHttpServer HttpServer
50 { 54 {
51 get { return m_HttpServer; } 55 get { return m_HttpServer; }
52 } 56 }
53 57
58 public uint DefaultPort
59 {
60 get { return m_Port; }
61 }
62
63 public IHttpServer GetHttpServer(uint port)
64 {
65 m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
66 if (port == m_Port)
67 return HttpServer;
68
69 if (m_Servers.ContainsKey(port))
70 return m_Servers[port];
71
72 m_Servers[port] = new BaseHttpServer(port);
73 m_Servers[port].Start();
74
75 return m_Servers[port];
76 }
77
54 // Handle all the automagical stuff 78 // Handle all the automagical stuff
55 // 79 //
56 public HttpServerBase(string prompt, string[] args) : base(prompt, args) 80 public HttpServerBase(string prompt, string[] args) : base(prompt, args)
@@ -74,6 +98,8 @@ namespace OpenSim.Server.Base
74 Thread.CurrentThread.Abort(); 98 Thread.CurrentThread.Abort();
75 } 99 }
76 100
101 m_Port = port;
102
77 m_HttpServer = new BaseHttpServer(port); 103 m_HttpServer = new BaseHttpServer(port);
78 104
79 MainServer.Instance = m_HttpServer; 105 MainServer.Instance = m_HttpServer;
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 6c2b3ed..2340645 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -141,7 +141,9 @@ namespace OpenSim.Server.Base
141 } 141 }
142 catch (Exception e) 142 catch (Exception e)
143 { 143 {
144 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); 144 if (!(e is System.MissingMethodException))
145 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
146 return null;
145 } 147 }
146 148
147 return plug; 149 return plug;
@@ -258,6 +260,8 @@ namespace OpenSim.Server.Base
258 260
259 public static Dictionary<string, object> ParseXmlResponse(string data) 261 public static Dictionary<string, object> ParseXmlResponse(string data)
260 { 262 {
263 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
264
261 Dictionary<string, object> ret = new Dictionary<string, object>(); 265 Dictionary<string, object> ret = new Dictionary<string, object>();
262 266
263 XmlDocument doc = new XmlDocument(); 267 XmlDocument doc = new XmlDocument();
@@ -284,7 +288,7 @@ namespace OpenSim.Server.Base
284 288
285 foreach (XmlNode part in partL) 289 foreach (XmlNode part in partL)
286 { 290 {
287 XmlNode type = part.Attributes.GetNamedItem("Type"); 291 XmlNode type = part.Attributes.GetNamedItem("type");
288 if (type == null || type.Value != "List") 292 if (type == null || type.Value != "List")
289 { 293 {
290 ret[part.Name] = part.InnerText; 294 ret[part.Name] = part.InnerText;
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 7c74e05..f7eb292 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Asset
37 public class AssetServiceConnector : ServiceConnector 37 public class AssetServiceConnector : ServiceConnector
38 { 38 {
39 private IAssetService m_AssetService; 39 private IAssetService m_AssetService;
40 private string m_ConfigName = "AssetService";
40 41
41 public AssetServiceConnector(IConfigSource config, IHttpServer server) : 42 public AssetServiceConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AssetService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string assetService = serverConfig.GetString("LocalServiceModule", 52 string assetService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 53 String.Empty);
@@ -55,7 +59,6 @@ namespace OpenSim.Server.Handlers.Asset
55 m_AssetService = 59 m_AssetService =
56 ServerUtils.LoadPlugin<IAssetService>(assetService, args); 60 ServerUtils.LoadPlugin<IAssetService>(assetService, args);
57 61
58 //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no"));
59 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); 62 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
60 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); 63 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService));
61 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService)); 64 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService));
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
index 589dc3b..2abef0a 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
@@ -37,13 +37,17 @@ namespace OpenSim.Server.Handlers.Authentication
37 public class AuthenticationServiceConnector : ServiceConnector 37 public class AuthenticationServiceConnector : ServiceConnector
38 { 38 {
39 private IAuthenticationService m_AuthenticationService; 39 private IAuthenticationService m_AuthenticationService;
40 private string m_ConfigName = "AuthenticationService";
40 41
41 public AuthenticationServiceConnector(IConfigSource config, IHttpServer server) : 42 public AuthenticationServiceConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AuthenticationService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string authenticationService = serverConfig.GetString("AuthenticationServiceModule", 52 string authenticationService = serverConfig.GetString("AuthenticationServiceModule",
49 String.Empty); 53 String.Empty);
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
index 0d9f239..20fd0f7 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerConnector.cs
@@ -37,13 +37,16 @@ namespace OpenSim.Server.Handlers.Authorization
37 public class AuthorizationServerConnector : ServiceConnector 37 public class AuthorizationServerConnector : ServiceConnector
38 { 38 {
39 private IAuthorizationService m_AuthorizationService; 39 private IAuthorizationService m_AuthorizationService;
40 private string m_ConfigName = "AuthorizationService";
40 41
41 public AuthorizationServerConnector(IConfigSource config, IHttpServer server) : 42 public AuthorizationServerConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["AuthorizationService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 48 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 49 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 50
48 string authorizationService = serverConfig.GetString("LocalServiceModule", 51 string authorizationService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 52 String.Empty);
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
index 69acd25..f987de4 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Server.Handlers.Authorization
44{ 44{
45 public class AuthorizationServerPostHandler : BaseStreamHandler 45 public class AuthorizationServerPostHandler : BaseStreamHandler
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private IAuthorizationService m_AuthorizationService; 49 private IAuthorizationService m_AuthorizationService;
50 50
diff --git a/OpenSim/Server/Handlers/Base/ServerConnector.cs b/OpenSim/Server/Handlers/Base/ServerConnector.cs
index 62fe773..71876da 100644
--- a/OpenSim/Server/Handlers/Base/ServerConnector.cs
+++ b/OpenSim/Server/Handlers/Base/ServerConnector.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Server.Handlers.Base
39 39
40 public class ServiceConnector : IServiceConnector 40 public class ServiceConnector : IServiceConnector
41 { 41 {
42 public ServiceConnector(IConfigSource config, IHttpServer server) 42 public ServiceConnector(IConfigSource config, IHttpServer server, string configName)
43 { 43 {
44 } 44 }
45 } 45 }
diff --git a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
index a4ab0d3..07bafc8 100644
--- a/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
+++ b/OpenSim/Server/Handlers/Freeswitch/FreeswitchServerConnector.cs
@@ -37,19 +37,23 @@ namespace OpenSim.Server.Handlers.Freeswitch
37 public class FreeswitchServerConnector : ServiceConnector 37 public class FreeswitchServerConnector : ServiceConnector
38 { 38 {
39 private IFreeswitchService m_FreeswitchService; 39 private IFreeswitchService m_FreeswitchService;
40 private string m_ConfigName = "FreeswitchService";
40 41
41 public FreeswitchServerConnector(IConfigSource config, IHttpServer server) : 42 public FreeswitchServerConnector(IConfigSource config, IHttpServer server, string configName) :
42 base(config, server) 43 base(config, server, configName)
43 { 44 {
44 IConfig serverConfig = config.Configs["FreeswitchService"]; 45 if (configName != String.Empty)
46 m_ConfigName = configName;
47
48 IConfig serverConfig = config.Configs[m_ConfigName];
45 if (serverConfig == null) 49 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 50 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
47 51
48 string freeswitchService = serverConfig.GetString("LocalServiceModule", 52 string freeswitchService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 53 String.Empty);
50 54
51 if (freeswitchService == String.Empty) 55 if (freeswitchService == String.Empty)
52 throw new Exception("No FreeswitchService in config file"); 56 throw new Exception("No LocalServiceModule in config file");
53 57
54 Object[] args = new Object[] { config }; 58 Object[] args = new Object[] { config };
55 m_FreeswitchService = 59 m_FreeswitchService =
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
new file mode 100644
index 0000000..14daf12
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
@@ -0,0 +1,61 @@
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 Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base;
34
35namespace OpenSim.Server.Handlers.Grid
36{
37 public class GridServiceConnector : ServiceConnector
38 {
39 private IGridService m_GridService;
40 private string m_ConfigName = "GridService";
41
42 public GridServiceConnector(IConfigSource config, IHttpServer server, string configName) :
43 base(config, server, configName)
44 {
45 IConfig serverConfig = config.Configs[m_ConfigName];
46 if (serverConfig == null)
47 throw new Exception(String.Format("No section {0} in config file", m_ConfigName));
48
49 string gridService = serverConfig.GetString("LocalServiceModule",
50 String.Empty);
51
52 if (gridService == String.Empty)
53 throw new Exception("No LocalServiceModule in config file");
54
55 Object[] args = new Object[] { config };
56 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
57
58 server.AddStreamHandler(new GridServerPostHandler(m_GridService));
59 }
60 }
61}
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
new file mode 100644
index 0000000..b9a4867
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -0,0 +1,433 @@
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;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42using OpenSim.Framework;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenMetaverse;
45
46namespace OpenSim.Server.Handlers.Grid
47{
48 public class GridServerPostHandler : BaseStreamHandler
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private IGridService m_GridService;
53
54 public GridServerPostHandler(IGridService service) :
55 base("POST", "/grid")
56 {
57 m_GridService = service;
58 }
59
60 public override byte[] Handle(string path, Stream requestData,
61 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
62 {
63 StreamReader sr = new StreamReader(requestData);
64 string body = sr.ReadToEnd();
65 sr.Close();
66 body = body.Trim();
67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
69
70 Dictionary<string, string> request =
71 ServerUtils.ParseQueryString(body);
72
73 if (!request.ContainsKey("METHOD"))
74 return FailureResult();
75
76 string method = request["METHOD"];
77
78 switch (method)
79 {
80 case "register":
81 return Register(request);
82
83 case "deregister":
84 return Deregister(request);
85
86 case "get_neighbours":
87 return GetNeighbours(request);
88
89 case "get_region_by_uuid":
90 return GetRegionByUUID(request);
91
92 case "get_region_by_position":
93 return GetRegionByPosition(request);
94
95 case "get_region_by_name":
96 return GetRegionByName(request);
97
98 case "get_regions_by_name":
99 return GetRegionsByName(request);
100
101 case "get_region_range":
102 return GetRegionRange(request);
103
104 }
105
106 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
107 return FailureResult();
108
109 }
110
111 #region Method-specific handlers
112
113 byte[] Register(Dictionary<string, string> request)
114 {
115 UUID scopeID = UUID.Zero;
116 if (request["SCOPEID"] != null)
117 UUID.TryParse(request["SCOPEID"], out scopeID);
118 else
119 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
120
121 Dictionary<string, object> rinfoData = new Dictionary<string, object>();
122 foreach (KeyValuePair<string, string> kvp in request)
123 rinfoData[kvp.Key] = kvp.Value;
124 GridRegion rinfo = new GridRegion(rinfoData);
125
126 bool result = m_GridService.RegisterRegion(scopeID, rinfo);
127
128 if (result)
129 return SuccessResult();
130 else
131 return FailureResult();
132 }
133
134 byte[] Deregister(Dictionary<string, string> request)
135 {
136 UUID regionID = UUID.Zero;
137 if (request["REGIONID"] != null)
138 UUID.TryParse(request["REGIONID"], out regionID);
139 else
140 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to deregister region");
141
142 bool result = m_GridService.DeregisterRegion(regionID);
143
144 if (result)
145 return SuccessResult();
146 else
147 return FailureResult();
148
149 }
150
151 byte[] GetNeighbours(Dictionary<string, string> request)
152 {
153 UUID scopeID = UUID.Zero;
154 if (request["SCOPEID"] != null)
155 UUID.TryParse(request["SCOPEID"], out scopeID);
156 else
157 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
158
159 UUID regionID = UUID.Zero;
160 if (request["REGIONID"] != null)
161 UUID.TryParse(request["REGIONID"], out regionID);
162 else
163 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
164
165 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
166 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
167
168 Dictionary<string, object> result = new Dictionary<string, object>();
169 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
170 result["result"] = "null";
171 else
172 {
173 int i = 0;
174 foreach (GridRegion rinfo in rinfos)
175 {
176 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
177 result["region" + i] = rinfoDict;
178 i++;
179 }
180 }
181
182 string xmlString = ServerUtils.BuildXmlResponse(result);
183 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
184 UTF8Encoding encoding = new UTF8Encoding();
185 return encoding.GetBytes(xmlString);
186
187 }
188
189 byte[] GetRegionByUUID(Dictionary<string, string> request)
190 {
191 UUID scopeID = UUID.Zero;
192 if (request["SCOPEID"] != null)
193 UUID.TryParse(request["SCOPEID"], out scopeID);
194 else
195 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
196
197 UUID regionID = UUID.Zero;
198 if (request["REGIONID"] != null)
199 UUID.TryParse(request["REGIONID"], out regionID);
200 else
201 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
202
203 GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
204 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
205
206 Dictionary<string, object> result = new Dictionary<string, object>();
207 if (rinfo == null)
208 result["result"] = "null";
209 else
210 result["result"] = rinfo.ToKeyValuePairs();
211
212 string xmlString = ServerUtils.BuildXmlResponse(result);
213 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
214 UTF8Encoding encoding = new UTF8Encoding();
215 return encoding.GetBytes(xmlString);
216 }
217
218 byte[] GetRegionByPosition(Dictionary<string, string> request)
219 {
220 UUID scopeID = UUID.Zero;
221 if (request["SCOPEID"] != null)
222 UUID.TryParse(request["SCOPEID"], out scopeID);
223 else
224 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
225
226 int x = 0, y = 0;
227 if (request["X"] != null)
228 Int32.TryParse(request["X"], out x);
229 else
230 m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
231 if (request["Y"] != null)
232 Int32.TryParse(request["Y"], out y);
233 else
234 m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
235
236 GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
237 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
238
239 Dictionary<string, object> result = new Dictionary<string, object>();
240 if (rinfo == null)
241 result["result"] = "null";
242 else
243 result["result"] = rinfo.ToKeyValuePairs();
244
245 string xmlString = ServerUtils.BuildXmlResponse(result);
246 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
247 UTF8Encoding encoding = new UTF8Encoding();
248 return encoding.GetBytes(xmlString);
249 }
250
251 byte[] GetRegionByName(Dictionary<string, string> request)
252 {
253 UUID scopeID = UUID.Zero;
254 if (request["SCOPEID"] != null)
255 UUID.TryParse(request["SCOPEID"], out scopeID);
256 else
257 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
258
259 string regionName = string.Empty;
260 if (request["NAME"] != null)
261 regionName = request["NAME"];
262 else
263 m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
264
265 GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
266 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
267
268 Dictionary<string, object> result = new Dictionary<string, object>();
269 if (rinfo == null)
270 result["result"] = "null";
271 else
272 result["result"] = rinfo.ToKeyValuePairs();
273
274 string xmlString = ServerUtils.BuildXmlResponse(result);
275 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
276 UTF8Encoding encoding = new UTF8Encoding();
277 return encoding.GetBytes(xmlString);
278 }
279
280 byte[] GetRegionsByName(Dictionary<string, string> request)
281 {
282 UUID scopeID = UUID.Zero;
283 if (request["SCOPEID"] != null)
284 UUID.TryParse(request["SCOPEID"], out scopeID);
285 else
286 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
287
288 string regionName = string.Empty;
289 if (request["NAME"] != null)
290 regionName = request["NAME"];
291 else
292 m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
293
294 int max = 0;
295 if (request["MAX"] != null)
296 Int32.TryParse(request["MAX"], out max);
297 else
298 m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
299
300 List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
301 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
302
303 Dictionary<string, object> result = new Dictionary<string, object>();
304 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
305 result["result"] = "null";
306 else
307 {
308 int i = 0;
309 foreach (GridRegion rinfo in rinfos)
310 {
311 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
312 result["region" + i] = rinfoDict;
313 i++;
314 }
315 }
316
317 string xmlString = ServerUtils.BuildXmlResponse(result);
318 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
319 UTF8Encoding encoding = new UTF8Encoding();
320 return encoding.GetBytes(xmlString);
321 }
322
323 byte[] GetRegionRange(Dictionary<string, string> request)
324 {
325 //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
326 UUID scopeID = UUID.Zero;
327 if (request.ContainsKey("SCOPEID"))
328 UUID.TryParse(request["SCOPEID"], out scopeID);
329 else
330 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
331
332 int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
333 if (request.ContainsKey("XMIN"))
334 Int32.TryParse(request["XMIN"], out xmin);
335 else
336 m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
337 if (request.ContainsKey("XMAX"))
338 Int32.TryParse(request["XMAX"], out xmax);
339 else
340 m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
341 if (request.ContainsKey("YMIN"))
342 Int32.TryParse(request["YMIN"], out ymin);
343 else
344 m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
345 if (request.ContainsKey("YMAX"))
346 Int32.TryParse(request["YMAX"], out ymax);
347 else
348 m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
349
350
351 List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
352
353 Dictionary<string, object> result = new Dictionary<string, object>();
354 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
355 result["result"] = "null";
356 else
357 {
358 int i = 0;
359 foreach (GridRegion rinfo in rinfos)
360 {
361 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
362 result["region" + i] = rinfoDict;
363 i++;
364 }
365 }
366 string xmlString = ServerUtils.BuildXmlResponse(result);
367 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
368 UTF8Encoding encoding = new UTF8Encoding();
369 return encoding.GetBytes(xmlString);
370 }
371
372 #endregion
373
374 #region Misc
375
376 private byte[] SuccessResult()
377 {
378 XmlDocument doc = new XmlDocument();
379
380 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
381 "", "");
382
383 doc.AppendChild(xmlnode);
384
385 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
386 "");
387
388 doc.AppendChild(rootElement);
389
390 XmlElement result = doc.CreateElement("", "Result", "");
391 result.AppendChild(doc.CreateTextNode("Success"));
392
393 rootElement.AppendChild(result);
394
395 return DocToBytes(doc);
396 }
397
398 private byte[] FailureResult()
399 {
400 XmlDocument doc = new XmlDocument();
401
402 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
403 "", "");
404
405 doc.AppendChild(xmlnode);
406
407 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
408 "");
409
410 doc.AppendChild(rootElement);
411
412 XmlElement result = doc.CreateElement("", "Result", "");
413 result.AppendChild(doc.CreateTextNode("Failure"));
414
415 rootElement.AppendChild(result);
416
417 return DocToBytes(doc);
418 }
419
420 private byte[] DocToBytes(XmlDocument doc)
421 {
422 MemoryStream ms = new MemoryStream();
423 XmlTextWriter xw = new XmlTextWriter(ms, null);
424 xw.Formatting = Formatting.Indented;
425 doc.WriteTo(xw);
426 xw.Flush();
427
428 return ms.ToArray();
429 }
430
431 #endregion
432 }
433}
diff --git a/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
new file mode 100644
index 0000000..e226759
--- /dev/null
+++ b/OpenSim/Server/Handlers/Grid/HypergridServerConnector.cs
@@ -0,0 +1,112 @@
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;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Server.Handlers.Base;
39
40using log4net;
41using Nwc.XmlRpc;
42
43namespace OpenSim.Server.Handlers.Grid
44{
45 public class HypergridServiceInConnector : ServiceConnector
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private List<SimpleRegionInfo> m_RegionsOnSim = new List<SimpleRegionInfo>();
52
53 public HypergridServiceInConnector(IConfigSource config, IHttpServer server) :
54 base(config, server, String.Empty)
55 {
56 server.AddXmlRPCHandler("linkk_region", LinkRegionRequest, false);
57 }
58
59 /// <summary>
60 /// Someone wants to link to us
61 /// </summary>
62 /// <param name="request"></param>
63 /// <returns></returns>
64 public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
65 {
66 Hashtable requestData = (Hashtable)request.Params[0];
67 //string host = (string)requestData["host"];
68 //string portstr = (string)requestData["port"];
69 string name = (string)requestData["region_name"];
70
71 m_log.DebugFormat("[HGrid]: Hyperlink request");
72
73 SimpleRegionInfo regInfo = null;
74 foreach (SimpleRegionInfo r in m_RegionsOnSim)
75 {
76 if ((r.RegionName != null) && (name != null) && (r.RegionName.ToLower() == name.ToLower()))
77 {
78 regInfo = r;
79 break;
80 }
81 }
82
83 if (regInfo == null)
84 regInfo = m_RegionsOnSim[0]; // Send out the first region
85
86 Hashtable hash = new Hashtable();
87 hash["uuid"] = regInfo.RegionID.ToString();
88 hash["handle"] = regInfo.RegionHandle.ToString();
89 //m_log.Debug(">> Here " + regInfo.RegionHandle);
90 //hash["region_image"] = regInfo.RegionSettings.TerrainImageID.ToString();
91 hash["region_name"] = regInfo.RegionName;
92 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
93 //m_log.Debug(">> Here: " + regInfo.InternalEndPoint.Port);
94
95
96 XmlRpcResponse response = new XmlRpcResponse();
97 response.Value = hash;
98 return response;
99 }
100
101 public void AddRegion(SimpleRegionInfo rinfo)
102 {
103 m_RegionsOnSim.Add(rinfo);
104 }
105
106 public void RemoveRegion(SimpleRegionInfo rinfo)
107 {
108 if (m_RegionsOnSim.Contains(rinfo))
109 m_RegionsOnSim.Remove(rinfo);
110 }
111 }
112}
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 998b322..ca45263 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -54,19 +54,20 @@ namespace OpenSim.Server.Handlers.Inventory
54 //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); 54 //private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME);
55 55
56 private string m_userserver_url; 56 private string m_userserver_url;
57 private string m_ConfigName = "InventoryService";
57 58
58 public InventoryServiceInConnector(IConfigSource config, IHttpServer server) : 59 public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
59 base(config, server) 60 base(config, server, configName)
60 { 61 {
61 IConfig serverConfig = config.Configs["InventoryService"]; 62 IConfig serverConfig = config.Configs[m_ConfigName];
62 if (serverConfig == null) 63 if (serverConfig == null)
63 throw new Exception("No section 'InventoryService' in config file"); 64 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
64 65
65 string inventoryService = serverConfig.GetString("LocalServiceModule", 66 string inventoryService = serverConfig.GetString("LocalServiceModule",
66 String.Empty); 67 String.Empty);
67 68
68 if (inventoryService == String.Empty) 69 if (inventoryService == String.Empty)
69 throw new Exception("No InventoryService in config file"); 70 throw new Exception("No LocalServiceModule in config file");
70 71
71 Object[] args = new Object[] { config }; 72 Object[] args = new Object[] { config };
72 m_InventoryService = 73 m_InventoryService =
diff --git a/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
index 10e3b47..d368bd3 100644
--- a/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Land/LandServiceInConnector.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Land
46 // TODO : private IAuthenticationService m_AuthenticationService; 46 // TODO : private IAuthenticationService m_AuthenticationService;
47 47
48 public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) : 48 public LandServiceInConnector(IConfigSource source, IHttpServer server, ILandService service, IScene scene) :
49 base(source, server) 49 base(source, server, String.Empty)
50 { 50 {
51 m_LandService = service; 51 m_LandService = service;
52 if (m_LandService == null) 52 if (m_LandService == null)
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
index b3a91cf..ac2e75f 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourServiceInConnector.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Server.Handlers.Neighbour
46 private IAuthenticationService m_AuthenticationService = null; 46 private IAuthenticationService m_AuthenticationService = null;
47 47
48 public NeighbourServiceInConnector(IConfigSource source, IHttpServer server, INeighbourService nService, IScene scene) : 48 public NeighbourServiceInConnector(IConfigSource source, IHttpServer server, INeighbourService nService, IScene scene) :
49 base(source, server) 49 base(source, server, String.Empty)
50 { 50 {
51 51
52 m_NeighbourService = nService; 52 m_NeighbourService = nService;
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
index 0bb4713..fe93fa5 100644
--- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Server.Handlers.Simulation
41 private IAuthenticationService m_AuthenticationService; 41 private IAuthenticationService m_AuthenticationService;
42 42
43 public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) : 43 public SimulationServiceInConnector(IConfigSource config, IHttpServer server, IScene scene) :
44 base(config, server) 44 base(config, server, String.Empty)
45 { 45 {
46 IConfig serverConfig = config.Configs["SimulationService"]; 46 IConfig serverConfig = config.Configs["SimulationService"];
47 if (serverConfig == null) 47 if (serverConfig == null)
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index 77dfebb..a7b33c9 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -30,6 +30,7 @@ using log4net;
30using System.Reflection; 30using System.Reflection;
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Base; 34using OpenSim.Server.Base;
34using OpenSim.Server.Handlers.Base; 35using OpenSim.Server.Handlers.Base;
35 36
@@ -60,22 +61,59 @@ namespace OpenSim.Server
60 string connList = serverConfig.GetString("ServiceConnectors", String.Empty); 61 string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
61 string[] conns = connList.Split(new char[] {',', ' '}); 62 string[] conns = connList.Split(new char[] {',', ' '});
62 63
63 foreach (string conn in conns) 64 int i = 0;
65 foreach (string c in conns)
64 { 66 {
65 if (conn == String.Empty) 67 if (c == String.Empty)
66 continue; 68 continue;
67 69
70 string configName = String.Empty;
71 string conn = c;
72 uint port = 0;
73
74 string[] split1 = conn.Split(new char[] {'/'});
75 if (split1.Length > 1)
76 {
77 conn = split1[1];
78
79 string[] split2 = split1[0].Split(new char[] {'@'});
80 if (split2.Length > 1)
81 {
82 configName = split2[0];
83 port = Convert.ToUInt32(split2[1]);
84 }
85 else
86 {
87 port = Convert.ToUInt32(split1[0]);
88 }
89 }
68 string[] parts = conn.Split(new char[] {':'}); 90 string[] parts = conn.Split(new char[] {':'});
69 string friendlyName = parts[0]; 91 string friendlyName = parts[0];
70 if (parts.Length > 1) 92 if (parts.Length > 1)
71 friendlyName = parts[1]; 93 friendlyName = parts[1];
72 94
73 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); 95 IHttpServer server = m_Server.HttpServer;
96 if (port != 0)
97 server = m_Server.GetHttpServer(port);
74 98
75 Object[] modargs = new Object[] { m_Server.Config, m_Server.HttpServer }; 99 if (port != m_Server.DefaultPort)
76 IServiceConnector connector = 100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port);
77 ServerUtils.LoadPlugin<IServiceConnector>(conn, 101 else
102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
103
104 IServiceConnector connector = null;
105
106 Object[] modargs = new Object[] { m_Server.Config, server,
107 configName };
108 connector = ServerUtils.LoadPlugin<IServiceConnector>(conn,
78 modargs); 109 modargs);
110 if (connector == null)
111 {
112 modargs = new Object[] { m_Server.Config, server };
113 connector =
114 ServerUtils.LoadPlugin<IServiceConnector>(conn,
115 modargs);
116 }
79 117
80 if (connector != null) 118 if (connector != null)
81 { 119 {
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 8904461..dcf090e 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService
43 // 43 //
44 public class AuthenticationServiceBase : ServiceBase 44 public class AuthenticationServiceBase : ServiceBase
45 { 45 {
46 private static readonly ILog m_log = 46// private static readonly ILog m_log =
47 LogManager.GetLogger( 47// LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48// MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 protected IAuthenticationData m_Database; 50 protected IAuthenticationData m_Database;
51 51
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 6c99b66..d65665a 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
47 public class PasswordAuthenticationService : 47 public class PasswordAuthenticationService :
48 AuthenticationServiceBase, IAuthenticationService 48 AuthenticationServiceBase, IAuthenticationService
49 { 49 {
50 private static readonly ILog m_log = 50// private static readonly ILog m_log =
51 LogManager.GetLogger( 51// LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType); 52// MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config) : 54 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 55 base(config)
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 8831c8a..d1a5b0f 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -43,9 +43,9 @@ namespace OpenSim.Services.AuthenticationService
43 public class WebkeyAuthenticationService : 43 public class WebkeyAuthenticationService :
44 AuthenticationServiceBase, IAuthenticationService 44 AuthenticationServiceBase, IAuthenticationService
45 { 45 {
46 private static readonly ILog m_log = 46// private static readonly ILog m_log =
47 LogManager.GetLogger( 47// LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 48// MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 public WebkeyAuthenticationService(IConfigSource config) : 50 public WebkeyAuthenticationService(IConfigSource config) :
51 base(config) 51 base(config)
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
new file mode 100644
index 0000000..748892a
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -0,0 +1,448 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace OpenSim.Services.Connectors
43{
44 public class GridServicesConnector : IGridService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public GridServicesConnector()
53 {
54 }
55
56 public GridServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public GridServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig gridConfig = source.Configs["GridService"];
69 if (gridConfig == null)
70 {
71 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
72 throw new Exception("Grid connector init error");
73 }
74
75 string serviceURI = gridConfig.GetString("GridServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
81 throw new Exception("Grid connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86
87 #region IGridService
88
89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
90 {
91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
92 Dictionary<string, string> sendData = new Dictionary<string,string>();
93 foreach (KeyValuePair<string, object> kvp in rinfo)
94 sendData[kvp.Key] = (string)kvp.Value;
95
96 sendData["SCOPEID"] = scopeID.ToString();
97
98 sendData["METHOD"] = "register";
99
100 string reqString = ServerUtils.BuildQueryString(sendData);
101 //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
102 try
103 {
104 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
105 m_ServerURI + "/grid",
106 reqString);
107 if (reply != string.Empty)
108 {
109 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
110
111 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
112 return true;
113 }
114 else
115 m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
116 }
117 catch (Exception e)
118 {
119 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
120 }
121
122 return false;
123 }
124
125 public virtual bool DeregisterRegion(UUID regionID)
126 {
127 Dictionary<string, string> sendData = new Dictionary<string, string>();
128
129 sendData["REGIONID"] = regionID.ToString();
130
131 sendData["METHOD"] = "deregister";
132
133 try
134 {
135 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
136 m_ServerURI + "/grid",
137 ServerUtils.BuildQueryString(sendData));
138
139 if (reply != string.Empty)
140 {
141 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
142
143 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
144 return true;
145 }
146 else
147 m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
148 }
149 catch (Exception e)
150 {
151 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
152 }
153
154 return false;
155 }
156
157 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 {
159 Dictionary<string, string> sendData = new Dictionary<string, string>();
160
161 sendData["SCOPEID"] = scopeID.ToString();
162 sendData["REGIONID"] = regionID.ToString();
163
164 sendData["METHOD"] = "get_neighbours";
165
166 List<GridRegion> rinfos = new List<GridRegion>();
167
168 string reqString = ServerUtils.BuildQueryString(sendData);
169 string reply = string.Empty;
170 try
171 {
172 reply = SynchronousRestFormsRequester.MakeRequest("POST",
173 m_ServerURI + "/grid",
174 reqString);
175 }
176 catch (Exception e)
177 {
178 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
179 return rinfos;
180 }
181
182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
183
184 if (replyData != null)
185 {
186 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
187 //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
188 foreach (object r in rinfosList)
189 {
190 if (r is Dictionary<string, object>)
191 {
192 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
193 rinfos.Add(rinfo);
194 }
195 else
196 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
197 scopeID, regionID, r.GetType());
198 }
199 }
200 else
201 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
202 scopeID, regionID);
203
204 return rinfos;
205 }
206
207 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
208 {
209 Dictionary<string, string> sendData = new Dictionary<string, string>();
210
211 sendData["SCOPEID"] = scopeID.ToString();
212 sendData["REGIONID"] = regionID.ToString();
213
214 sendData["METHOD"] = "get_region_by_uuid";
215
216 string reply = string.Empty;
217 try
218 {
219 reply = SynchronousRestFormsRequester.MakeRequest("POST",
220 m_ServerURI + "/grid",
221 ServerUtils.BuildQueryString(sendData));
222 }
223 catch (Exception e)
224 {
225 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
226 return null;
227 }
228
229 GridRegion rinfo = null;
230
231 if (reply != string.Empty)
232 {
233 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
234
235 if ((replyData != null) && (replyData["result"] != null))
236 {
237 if (replyData["result"] is Dictionary<string, object>)
238 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
239 //else
240 // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
241 // scopeID, regionID);
242 }
243 else
244 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
245 scopeID, regionID);
246 }
247 else
248 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
249
250 return rinfo;
251 }
252
253 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
254 {
255 Dictionary<string, string> sendData = new Dictionary<string, string>();
256
257 sendData["SCOPEID"] = scopeID.ToString();
258 sendData["X"] = x.ToString();
259 sendData["Y"] = y.ToString();
260
261 sendData["METHOD"] = "get_region_by_position";
262 string reply = string.Empty;
263 try
264 {
265 reply = SynchronousRestFormsRequester.MakeRequest("POST",
266 m_ServerURI + "/grid",
267 ServerUtils.BuildQueryString(sendData));
268 }
269 catch (Exception e)
270 {
271 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
272 return null;
273 }
274
275 GridRegion rinfo = null;
276 if (reply != string.Empty)
277 {
278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
279
280 if ((replyData != null) && (replyData["result"] != null))
281 {
282 if (replyData["result"] is Dictionary<string, object>)
283 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
284 else
285 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
286 scopeID, x, y);
287 }
288 else
289 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
290 scopeID, x, y);
291 }
292 else
293 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
294
295 return rinfo;
296 }
297
298 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
299 {
300 Dictionary<string, string> sendData = new Dictionary<string, string>();
301
302 sendData["SCOPEID"] = scopeID.ToString();
303 sendData["NAME"] = regionName;
304
305 sendData["METHOD"] = "get_region_by_name";
306 string reply = string.Empty;
307 try
308 {
309 reply = SynchronousRestFormsRequester.MakeRequest("POST",
310 m_ServerURI + "/grid",
311 ServerUtils.BuildQueryString(sendData));
312 }
313 catch (Exception e)
314 {
315 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
316 return null;
317 }
318
319 GridRegion rinfo = null;
320 if (reply != string.Empty)
321 {
322 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
323
324 if ((replyData != null) && (replyData["result"] != null))
325 {
326 if (replyData["result"] is Dictionary<string, object>)
327 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
328 }
329 else
330 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
331 scopeID, regionName);
332 }
333 else
334 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
335
336 return rinfo;
337 }
338
339 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
340 {
341 Dictionary<string, string> sendData = new Dictionary<string, string>();
342
343 sendData["SCOPEID"] = scopeID.ToString();
344 sendData["NAME"] = name;
345 sendData["MAX"] = maxNumber.ToString();
346
347 sendData["METHOD"] = "get_regions_by_name";
348 List<GridRegion> rinfos = new List<GridRegion>();
349 string reply = string.Empty;
350 try
351 {
352 reply = SynchronousRestFormsRequester.MakeRequest("POST",
353 m_ServerURI + "/grid",
354 ServerUtils.BuildQueryString(sendData));
355 }
356 catch (Exception e)
357 {
358 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
359 return rinfos;
360 }
361
362 if (reply != string.Empty)
363 {
364 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
365
366 if (replyData != null)
367 {
368 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
369 foreach (object r in rinfosList)
370 {
371 if (r is Dictionary<string, object>)
372 {
373 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
374 rinfos.Add(rinfo);
375 }
376 else
377 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
378 scopeID, name, maxNumber);
379 }
380 }
381 else
382 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
383 scopeID, name, maxNumber);
384 }
385 else
386 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
387
388 return rinfos;
389 }
390
391 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
392 {
393 Dictionary<string, string> sendData = new Dictionary<string, string>();
394
395 sendData["SCOPEID"] = scopeID.ToString();
396 sendData["XMIN"] = xmin.ToString();
397 sendData["XMAX"] = xmax.ToString();
398 sendData["YMIN"] = ymin.ToString();
399 sendData["YMAX"] = ymax.ToString();
400
401 sendData["METHOD"] = "get_region_range";
402
403 List<GridRegion> rinfos = new List<GridRegion>();
404 string reply = string.Empty;
405 try
406 {
407 reply = SynchronousRestFormsRequester.MakeRequest("POST",
408 m_ServerURI + "/grid",
409 ServerUtils.BuildQueryString(sendData));
410
411 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
412 }
413 catch (Exception e)
414 {
415 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
416 return rinfos;
417 }
418
419 if (reply != string.Empty)
420 {
421 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
422
423 if (replyData != null)
424 {
425 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
426 foreach (object r in rinfosList)
427 {
428 if (r is Dictionary<string, object>)
429 {
430 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
431 rinfos.Add(rinfo);
432 }
433 }
434 }
435 else
436 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
437 scopeID, xmin, xmax, ymin, ymax);
438 }
439 else
440 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
441
442 return rinfos;
443 }
444
445 #endregion
446
447 }
448}
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..b5e8743
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -0,0 +1,152 @@
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;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Grid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
59 {
60 UUID uuid = UUID.Zero;
61 realHandle = 0;
62
63 Hashtable hash = new Hashtable();
64 hash["region_name"] = info.RegionName;
65
66 IList paramList = new ArrayList();
67 paramList.Add(hash);
68
69 XmlRpcRequest request = new XmlRpcRequest("linkk_region", paramList);
70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
71 m_log.Debug("[HGrid]: Linking to " + uri);
72 XmlRpcResponse response = request.Send(uri, 10000);
73 if (response.IsFault)
74 {
75 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
76 }
77 else
78 {
79 hash = (Hashtable)response.Value;
80 //foreach (Object o in hash)
81 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
82 try
83 {
84 UUID.TryParse((string)hash["uuid"], out uuid);
85 info.RegionID = uuid;
86 if ((string)hash["handle"] != null)
87 {
88 realHandle = Convert.ToUInt64((string)hash["handle"]);
89 m_log.Debug(">> HERE, realHandle: " + realHandle);
90 }
91 //if (hash["region_image"] != null)
92 //{
93 // UUID img = UUID.Zero;
94 // UUID.TryParse((string)hash["region_image"], out img);
95 // info.RegionSettings.TerrainImageID = img;
96 //}
97 if (hash["region_name"] != null)
98 {
99 info.RegionName = (string)hash["region_name"];
100 //m_log.Debug(">> " + info.RegionName);
101 }
102 if (hash["internal_port"] != null)
103 {
104 int port = Convert.ToInt32((string)hash["internal_port"]);
105 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
106 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
107 }
108
109 }
110 catch (Exception e)
111 {
112 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
113 }
114 }
115 return uuid;
116 }
117
118 public void GetMapImage(GridRegion info)
119 {
120 try
121 {
122 string regionimage = "regionImage" + info.RegionID.ToString();
123 regionimage = regionimage.Replace("-", "");
124
125 WebClient c = new WebClient();
126 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
127 //m_log.Debug("JPEG: " + uri);
128 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
129 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
130 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
131 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
132 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
133
134 // !!! for now
135 //info.RegionSettings.TerrainImageID = ass.FullID;
136
137 ass.Type = (int)AssetType.Texture;
138 ass.Temporary = true;
139 ass.Local = true;
140 ass.Data = imageData;
141
142 m_AssetService.Store(ass);
143
144 }
145 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
146 {
147 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
148 }
149 }
150
151 }
152}
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 6aa1c4f..991acf2 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Services.GridService 41namespace OpenSim.Services.GridService
@@ -48,33 +49,28 @@ namespace OpenSim.Services.GridService
48 public GridService(IConfigSource config) 49 public GridService(IConfigSource config)
49 : base(config) 50 : base(config)
50 { 51 {
51 MainConsole.Instance.Commands.AddCommand("kfs", false, 52 m_log.DebugFormat("[GRID SERVICE]: Starting...");
52 "show digest",
53 "show digest <ID>",
54 "Show asset digest", HandleShowDigest);
55
56 MainConsole.Instance.Commands.AddCommand("kfs", false,
57 "delete asset",
58 "delete asset <ID>",
59 "Delete asset from database", HandleDeleteAsset);
60
61 } 53 }
62 54
63 #region IGridService 55 #region IGridService
64 56
65 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) 57 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
66 { 58 {
67 if (m_Database.Get(regionInfos.RegionID, scopeID) != null) 59 // This needs better sanity testing. What if regionInfo is registering in
68 { 60 // overlapping coords?
69 m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); 61 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
70 return false; 62 if ((region != null) && (region.RegionID != regionInfos.RegionID))
71 }
72 if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null)
73 { 63 {
74 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 64 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
75 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 65 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
76 return false; 66 return false;
77 } 67 }
68 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
69 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
70 {
71 // Region reregistering in other coordinates. Delete the old entry
72 m_Database.Delete(regionInfos.RegionID);
73 }
78 74
79 // Everything is ok, let's register 75 // Everything is ok, let's register
80 RegionData rdata = RegionInfo2RegionData(regionInfos); 76 RegionData rdata = RegionInfo2RegionData(regionInfos);
@@ -88,17 +84,25 @@ namespace OpenSim.Services.GridService
88 return m_Database.Delete(regionID); 84 return m_Database.Delete(regionID);
89 } 85 }
90 86
91 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y) 87 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
92 { 88 {
93 List<RegionData> rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); 89 List<GridRegion> rinfos = new List<GridRegion>();
94 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 90 RegionData region = m_Database.Get(regionID, scopeID);
95 foreach (RegionData rdata in rdatas) 91 if (region != null)
96 rinfos.Add(RegionData2RegionInfo(rdata)); 92 {
93 // Not really? Maybe?
94 List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize,
95 region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID);
96
97 foreach (RegionData rdata in rdatas)
98 if (rdata.RegionID != regionID)
99 rinfos.Add(RegionData2RegionInfo(rdata));
97 100
101 }
98 return rinfos; 102 return rinfos;
99 } 103 }
100 104
101 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) 105 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
102 { 106 {
103 RegionData rdata = m_Database.Get(regionID, scopeID); 107 RegionData rdata = m_Database.Get(regionID, scopeID);
104 if (rdata != null) 108 if (rdata != null)
@@ -107,16 +111,18 @@ namespace OpenSim.Services.GridService
107 return null; 111 return null;
108 } 112 }
109 113
110 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) 114 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
111 { 115 {
112 RegionData rdata = m_Database.Get(x, y, scopeID); 116 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
117 int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
118 RegionData rdata = m_Database.Get(snapX, snapY, scopeID);
113 if (rdata != null) 119 if (rdata != null)
114 return RegionData2RegionInfo(rdata); 120 return RegionData2RegionInfo(rdata);
115 121
116 return null; 122 return null;
117 } 123 }
118 124
119 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) 125 public GridRegion GetRegionByName(UUID scopeID, string regionName)
120 { 126 {
121 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); 127 List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID);
122 if ((rdatas != null) && (rdatas.Count > 0)) 128 if ((rdatas != null) && (rdatas.Count > 0))
@@ -125,12 +131,12 @@ namespace OpenSim.Services.GridService
125 return null; 131 return null;
126 } 132 }
127 133
128 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) 134 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
129 { 135 {
130 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); 136 List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID);
131 137
132 int count = 0; 138 int count = 0;
133 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 139 List<GridRegion> rinfos = new List<GridRegion>();
134 140
135 if (rdatas != null) 141 if (rdatas != null)
136 { 142 {
@@ -144,10 +150,15 @@ namespace OpenSim.Services.GridService
144 return rinfos; 150 return rinfos;
145 } 151 }
146 152
147 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) 153 public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
148 { 154 {
149 List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); 155 int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
150 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); 156 int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
157 int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
158 int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
159
160 List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
161 List<GridRegion> rinfos = new List<GridRegion>();
151 foreach (RegionData rdata in rdatas) 162 foreach (RegionData rdata in rdatas)
152 rinfos.Add(RegionData2RegionInfo(rdata)); 163 rinfos.Add(RegionData2RegionInfo(rdata));
153 164
@@ -158,140 +169,31 @@ namespace OpenSim.Services.GridService
158 169
159 #region Data structure conversions 170 #region Data structure conversions
160 171
161 protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) 172 protected RegionData RegionInfo2RegionData(GridRegion rinfo)
162 { 173 {
163 RegionData rdata = new RegionData(); 174 RegionData rdata = new RegionData();
164 rdata.posX = (int)rinfo.RegionLocX; 175 rdata.posX = (int)rinfo.RegionLocX;
165 rdata.posY = (int)rinfo.RegionLocY; 176 rdata.posY = (int)rinfo.RegionLocY;
166 rdata.RegionID = rinfo.RegionID; 177 rdata.RegionID = rinfo.RegionID;
167 //rdata.RegionName = rinfo.RegionName; 178 rdata.RegionName = rinfo.RegionName;
168 rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); 179 rdata.Data = rinfo.ToKeyValuePairs();
169 rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); 180 rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
170 rdata.Data["external_host_name"] = rinfo.ExternalHostName;
171 rdata.Data["http_port"] = rinfo.HttpPort.ToString();
172 rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString();
173 rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString();
174 rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString();
175 rdata.Data["server_uri"] = rinfo.ServerURI;
176
177 return rdata; 181 return rdata;
178 } 182 }
179 183
180 protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) 184 protected GridRegion RegionData2RegionInfo(RegionData rdata)
181 { 185 {
182 SimpleRegionInfo rinfo = new SimpleRegionInfo(); 186 GridRegion rinfo = new GridRegion(rdata.Data);
183 rinfo.RegionLocX = (uint)rdata.posX; 187 rinfo.RegionLocX = rdata.posX;
184 rinfo.RegionLocY = (uint)rdata.posY; 188 rinfo.RegionLocY = rdata.posY;
185 rinfo.RegionID = rdata.RegionID; 189 rinfo.RegionID = rdata.RegionID;
186 //rinfo.RegionName = rdata.RegionName; 190 rinfo.RegionName = rdata.RegionName;
187 191 rinfo.ScopeID = rdata.ScopeID;
188 // Now for the variable data
189 if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null))
190 {
191 int port = 0;
192 Int32.TryParse((string)rdata.Data["external_port"], out port);
193 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port);
194 rinfo.ExternalEndPoint = ep;
195 }
196 else
197 rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0);
198
199 if (rdata.Data["external_host_name"] != null)
200 rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ;
201
202 if (rdata.Data["http_port"] != null)
203 {
204 UInt32 port = 0;
205 UInt32.TryParse((string)rdata.Data["http_port"], out port);
206 rinfo.HttpPort = port;
207 }
208
209 if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null))
210 {
211 int port = 0;
212 Int32.TryParse((string)rdata.Data["internal_port"], out port);
213 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port);
214 rinfo.InternalEndPoint = ep;
215 }
216 else
217 rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0);
218
219 if (rdata.Data["alternate_ports"] != null)
220 {
221 bool alts = false;
222 Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts);
223 rinfo.m_allow_alternate_ports = alts;
224 }
225
226 if (rdata.Data["server_uri"] != null)
227 rinfo.ServerURI = (string)rdata.Data["server_uri"];
228 192
229 return rinfo; 193 return rinfo;
230 } 194 }
231 195
232 #endregion 196 #endregion
233 197
234 void HandleShowDigest(string module, string[] args)
235 {
236 //if (args.Length < 3)
237 //{
238 // MainConsole.Instance.Output("Syntax: show digest <ID>");
239 // return;
240 //}
241
242 //AssetBase asset = Get(args[2]);
243
244 //if (asset == null || asset.Data.Length == 0)
245 //{
246 // MainConsole.Instance.Output("Asset not found");
247 // return;
248 //}
249
250 //int i;
251
252 //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
253 //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
254 //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
255 //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
256
257 //for (i = 0 ; i < 5 ; i++)
258 //{
259 // int off = i * 16;
260 // if (asset.Data.Length <= off)
261 // break;
262 // int len = 16;
263 // if (asset.Data.Length < off + len)
264 // len = asset.Data.Length - off;
265
266 // byte[] line = new byte[len];
267 // Array.Copy(asset.Data, off, line, 0, len);
268
269 // string text = BitConverter.ToString(line);
270 // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
271 //}
272 }
273
274 void HandleDeleteAsset(string module, string[] args)
275 {
276 //if (args.Length < 3)
277 //{
278 // MainConsole.Instance.Output("Syntax: delete asset <ID>");
279 // return;
280 //}
281
282 //AssetBase asset = Get(args[2]);
283
284 //if (asset == null || asset.Data.Length == 0)
285 // MainConsole.Instance.Output("Asset not found");
286 // return;
287 //}
288
289 //Delete(args[2]);
290
291 ////MainConsole.Instance.Output("Asset deleted");
292 //// TODO: Implement this
293
294 //MainConsole.Instance.Output("Asset deletion not supported by database");
295 }
296 } 198 }
297} 199}
diff --git a/OpenSim/Services/GridService/GridServiceBase.cs b/OpenSim/Services/GridService/GridServiceBase.cs
index 7b69290..444f79b 100644
--- a/OpenSim/Services/GridService/GridServiceBase.cs
+++ b/OpenSim/Services/GridService/GridServiceBase.cs
@@ -47,17 +47,6 @@ namespace OpenSim.Services.GridService
47 string realm = "regions"; 47 string realm = "regions";
48 48
49 // 49 //
50 // Try reading the [AssetService] section first, if it exists
51 //
52 IConfig gridConfig = config.Configs["GridService"];
53 if (gridConfig != null)
54 {
55 dllName = gridConfig.GetString("StorageProvider", dllName);
56 connString = gridConfig.GetString("ConnectionString", connString);
57 realm = gridConfig.GetString("Realm", realm);
58 }
59
60 //
61 // Try reading the [DatabaseService] section, if it exists 50 // Try reading the [DatabaseService] section, if it exists
62 // 51 //
63 IConfig dbConfig = config.Configs["DatabaseService"]; 52 IConfig dbConfig = config.Configs["DatabaseService"];
@@ -70,6 +59,17 @@ namespace OpenSim.Services.GridService
70 } 59 }
71 60
72 // 61 //
62 // [GridService] section overrides [DatabaseService], if it exists
63 //
64 IConfig gridConfig = config.Configs["GridService"];
65 if (gridConfig != null)
66 {
67 dllName = gridConfig.GetString("StorageProvider", dllName);
68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm);
70 }
71
72 //
73 // We tried, but this doesn't exist. We can't proceed. 73 // We tried, but this doesn't exist. We can't proceed.
74 // 74 //
75 if (dllName.Equals(String.Empty)) 75 if (dllName.Equals(String.Empty))
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 83ab9c1..ce432ab 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -25,8 +25,11 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenSim.Framework; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using OpenSim.Framework;
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
39 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
40 /// <returns></returns> 43 /// <returns></returns>
41 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
42 bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos); 45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
43 46
44 /// <summary> 47 /// <summary>
45 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.
@@ -55,9 +58,9 @@ namespace OpenSim.Services.Interfaces
55 /// <param name="x"></param> 58 /// <param name="x"></param>
56 /// <param name="y"></param> 59 /// <param name="y"></param>
57 /// <returns></returns> 60 /// <returns></returns>
58 List<SimpleRegionInfo> GetNeighbours(UUID scopeID, int x, int y); 61 List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
59 62
60 SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); 63 GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
61 64
62 /// <summary> 65 /// <summary>
63 /// Get the region at the given position (in meters) 66 /// Get the region at the given position (in meters)
@@ -66,9 +69,9 @@ namespace OpenSim.Services.Interfaces
66 /// <param name="x"></param> 69 /// <param name="x"></param>
67 /// <param name="y"></param> 70 /// <param name="y"></param>
68 /// <returns></returns> 71 /// <returns></returns>
69 SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); 72 GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
70 73
71 SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName); 74 GridRegion GetRegionByName(UUID scopeID, string regionName);
72 75
73 /// <summary> 76 /// <summary>
74 /// Get information about regions starting with the provided name. 77 /// Get information about regions starting with the provided name.
@@ -83,9 +86,233 @@ namespace OpenSim.Services.Interfaces
83 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 86 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
84 /// grid-server couldn't be contacted or returned an error, return null. 87 /// grid-server couldn't be contacted or returned an error, return null.
85 /// </returns> 88 /// </returns>
86 List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); 89 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
87 90
88 List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 91 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
89 92
90 } 93 }
94
95 public class GridRegion
96 {
97
98 /// <summary>
99 /// The port by which http communication occurs with the region
100 /// </summary>
101 public uint HttpPort
102 {
103 get { return m_httpPort; }
104 set { m_httpPort = value; }
105 }
106 protected uint m_httpPort;
107
108 /// <summary>
109 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
110 /// </summary>
111 public string ServerURI
112 {
113 get { return m_serverURI; }
114 set { m_serverURI = value; }
115 }
116 protected string m_serverURI;
117
118 public string RegionName
119 {
120 get { return m_regionName; }
121 set { m_regionName = value; }
122 }
123 protected string m_regionName = String.Empty;
124
125 protected bool Allow_Alternate_Ports;
126 public bool m_allow_alternate_ports;
127
128 protected string m_externalHostName;
129
130 protected IPEndPoint m_internalEndPoint;
131
132 public int RegionLocX
133 {
134 get { return m_regionLocX; }
135 set { m_regionLocX = value; }
136 }
137 protected int m_regionLocX;
138
139 public int RegionLocY
140 {
141 get { return m_regionLocY; }
142 set { m_regionLocY = value; }
143 }
144 protected int m_regionLocY;
145
146 public UUID RegionID = UUID.Zero;
147 public UUID ScopeID = UUID.Zero;
148
149 public GridRegion()
150 {
151 }
152
153 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
154 {
155 m_regionLocX = regionLocX;
156 m_regionLocY = regionLocY;
157
158 m_internalEndPoint = internalEndPoint;
159 m_externalHostName = externalUri;
160 }
161
162 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
163 {
164 m_regionLocX = regionLocX;
165 m_regionLocY = regionLocY;
166
167 m_externalHostName = externalUri;
168
169 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
170 }
171
172 public GridRegion(uint xcell, uint ycell)
173 {
174 m_regionLocX = (int)(xcell * Constants.RegionSize);
175 m_regionLocY = (int)(ycell * Constants.RegionSize);
176 }
177
178 public GridRegion(RegionInfo ConvertFrom)
179 {
180 m_regionName = ConvertFrom.RegionName;
181 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
182 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
183 m_internalEndPoint = ConvertFrom.InternalEndPoint;
184 m_externalHostName = ConvertFrom.ExternalHostName;
185 m_httpPort = ConvertFrom.HttpPort;
186 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
187 RegionID = UUID.Zero;
188 ServerURI = ConvertFrom.ServerURI;
189 }
190
191
192 /// <value>
193 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
194 ///
195 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
196 /// </value>
197 public IPEndPoint ExternalEndPoint
198 {
199 get
200 {
201 // Old one defaults to IPv6
202 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
203
204 IPAddress ia = null;
205 // If it is already an IP, don't resolve it - just return directly
206 if (IPAddress.TryParse(m_externalHostName, out ia))
207 return new IPEndPoint(ia, m_internalEndPoint.Port);
208
209 // Reset for next check
210 ia = null;
211 try
212 {
213 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
214 {
215 if (ia == null)
216 ia = Adr;
217
218 if (Adr.AddressFamily == AddressFamily.InterNetwork)
219 {
220 ia = Adr;
221 break;
222 }
223 }
224 }
225 catch (SocketException e)
226 {
227 throw new Exception(
228 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
229 e + "' attached to this exception", e);
230 }
231
232 return new IPEndPoint(ia, m_internalEndPoint.Port);
233 }
234
235 set { m_externalHostName = value.ToString(); }
236 }
237
238 public string ExternalHostName
239 {
240 get { return m_externalHostName; }
241 set { m_externalHostName = value; }
242 }
243
244 public IPEndPoint InternalEndPoint
245 {
246 get { return m_internalEndPoint; }
247 set { m_internalEndPoint = value; }
248 }
249
250 public ulong RegionHandle
251 {
252 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
253 }
254
255 public int getInternalEndPointPort()
256 {
257 return m_internalEndPoint.Port;
258 }
259
260 public Dictionary<string, object> ToKeyValuePairs()
261 {
262 Dictionary<string, object> kvp = new Dictionary<string, object>();
263 kvp["uuid"] = RegionID.ToString();
264 kvp["locX"] = RegionLocX.ToString();
265 kvp["locY"] = RegionLocY.ToString();
266 kvp["regionName"] = RegionName;
267 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
268 kvp["serverHttpPort"] = HttpPort.ToString();
269 kvp["serverURI"] = ServerURI;
270 kvp["serverPort"] = InternalEndPoint.Port.ToString();
271
272 return kvp;
273 }
274
275 public GridRegion(Dictionary<string, object> kvp)
276 {
277 if (kvp.ContainsKey("uuid"))
278 RegionID = new UUID((string)kvp["uuid"]);
279
280 if (kvp.ContainsKey("locX"))
281 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
282
283 if (kvp.ContainsKey("locY"))
284 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
285
286 if (kvp.ContainsKey("regionName"))
287 RegionName = (string)kvp["regionName"];
288
289 if (kvp.ContainsKey("serverIP"))
290 {
291 //int port = 0;
292 //Int32.TryParse((string)kvp["serverPort"], out port);
293 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
294 ExternalHostName = (string)kvp["serverIP"];
295 }
296 else
297 ExternalHostName = "127.0.0.1";
298
299 if (kvp.ContainsKey("serverPort"))
300 {
301 Int32 port = 0;
302 Int32.TryParse((string)kvp["serverPort"], out port);
303 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
304 }
305
306 if (kvp.ContainsKey("serverHttpPort"))
307 {
308 UInt32 port = 0;
309 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
310 HttpPort = port;
311 }
312
313 if (kvp.ContainsKey("serverURI"))
314 ServerURI = (string)kvp["serverURI"];
315 }
316 }
317
91} 318}
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..941406e
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,177 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Reflection;
5
6using OpenMetaverse;
7using log4net;
8using log4net.Appender;
9using log4net.Layout;
10
11using OpenSim.Framework;
12using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14using OpenSim.Services.Connectors;
15
16namespace OpenSim.Tests.Clients.GridClient
17{
18 public class GridClient
19 {
20 private static readonly ILog m_log =
21 LogManager.GetLogger(
22 MethodBase.GetCurrentMethod().DeclaringType);
23
24 public static void Main(string[] args)
25 {
26 ConsoleAppender consoleAppender = new ConsoleAppender();
27 consoleAppender.Layout =
28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
29 log4net.Config.BasicConfigurator.Configure(consoleAppender);
30
31 string serverURI = "http://127.0.0.1:8002";
32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
33
34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
35 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
36 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
37
38 Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
39 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
40 if (success)
41 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
42 else
43 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
44
45 Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
46 success = m_Connector.RegisterRegion(UUID.Zero, r2);
47 if (success)
48 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
49 else
50 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
51
52 Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
53 success = m_Connector.RegisterRegion(UUID.Zero, r3);
54 if (success)
55 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
56 else
57 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
58
59
60 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
61 success = m_Connector.DeregisterRegion(r3.RegionID);
62 if (success)
63 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
64 else
65 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
66 Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
67 success = m_Connector.RegisterRegion(UUID.Zero, r3);
68 if (success)
69 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
70 else
71 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
72
73 Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
74 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
75 if (regions == null)
76 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
77 else if (regions.Count > 0)
78 {
79 if (regions.Count != 1)
80 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
81 else
82 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
83 }
84 else
85 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
86
87
88 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
89 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
90 if (region == null)
91 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
92 else
93 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
94
95 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
96 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
97 if (region == null)
98 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
99 else
100 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
101
102 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
103 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
104 if (region == null)
105 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
106 else
107 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
108
109 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
110 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
111 if (region == null)
112 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
113 else
114 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
115
116 Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
117 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
118 if (regions == null)
119 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
120 else
121 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
122
123 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
124 regions = m_Connector.GetRegionRange(UUID.Zero,
125 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
126 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
127 if (regions == null)
128 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
129 else
130 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
131 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
132 regions = m_Connector.GetRegionRange(UUID.Zero,
133 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
134 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
135 if (regions == null)
136 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
137 else
138 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
139
140 Console.Write("Proceed to deregister? Press enter...");
141 Console.ReadLine();
142
143 // Deregister them all
144 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
145 success = m_Connector.DeregisterRegion(r1.RegionID);
146 if (success)
147 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
148 else
149 Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
150 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
151 success = m_Connector.DeregisterRegion(r2.RegionID);
152 if (success)
153 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
154 else
155 Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
156 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
157 success = m_Connector.DeregisterRegion(r3.RegionID);
158 if (success)
159 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
160 else
161 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
162
163 }
164
165 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
166 {
167 GridRegion region = new GridRegion(xcell, ycell);
168 region.RegionName = name;
169 region.RegionID = UUID.Random();
170 region.ExternalHostName = "127.0.0.1";
171 region.HttpPort = 9000;
172 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
173
174 return region;
175 }
176 }
177}
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Clients/Grid/GridForm.html
new file mode 100644
index 0000000..252920f
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridForm.html
@@ -0,0 +1,11 @@
1<html>
2
3<form name="input" action="http://127.0.0.1:8002/grid" method="post">
4xmin:<input type="text" name="XMIN" value="0">
5xmax:<input type="text" name="XMAX" value="0">
6ymin:<input type="text" name="YMIN" value="0">
7ymax:<input type="text" name="YMAX" value="0">
8<input type="hidden" name="METHOD" value="get_region_range">
9<input type="submit" value="Submit" />
10</form>
11</html>