diff options
author | Melanie | 2011-12-08 03:37:48 +0100 |
---|---|---|
committer | Melanie | 2011-12-08 03:37:48 +0100 |
commit | 7c7dd6269a0efff5b4619028825a46fcab84de63 (patch) | |
tree | cbe6c622fc1c069f3a33636fd1174d314dec074a /OpenSim | |
parent | Recover from an internal mess-up in the outgoing packet queues by creating (diff) | |
parent | Merge branch 'master' into bigmerge (diff) | |
download | opensim-SC-7c7dd6269a0efff5b4619028825a46fcab84de63.zip opensim-SC-7c7dd6269a0efff5b4619028825a46fcab84de63.tar.gz opensim-SC-7c7dd6269a0efff5b4619028825a46fcab84de63.tar.bz2 opensim-SC-7c7dd6269a0efff5b4619028825a46fcab84de63.tar.xz |
Merge branch 'bigmerge' of ssh://3dhosting.de/var/git/careminster into bigmerge
Diffstat (limited to 'OpenSim')
14 files changed, 1515 insertions, 1742 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 468eeb4..9298726 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -124,32 +124,38 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
124 | m_httpServer = MainServer.GetHttpServer((uint)port,ipaddr); | 124 | m_httpServer = MainServer.GetHttpServer((uint)port,ipaddr); |
125 | 125 | ||
126 | Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>(); | 126 | Dictionary<string, XmlRpcMethod> availableMethods = new Dictionary<string, XmlRpcMethod>(); |
127 | availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod; | 127 | availableMethods["admin_create_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateRegionMethod); |
128 | availableMethods["admin_delete_region"] = XmlRpcDeleteRegionMethod; | 128 | availableMethods["admin_delete_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDeleteRegionMethod); |
129 | availableMethods["admin_close_region"] = XmlRpcCloseRegionMethod; | 129 | availableMethods["admin_close_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCloseRegionMethod); |
130 | availableMethods["admin_modify_region"] = XmlRpcModifyRegionMethod; | 130 | availableMethods["admin_modify_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcModifyRegionMethod); |
131 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; | 131 | availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); |
132 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; | 132 | availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); |
133 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; | 133 | availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); |
134 | availableMethods["admin_dialog"] = XmlRpcDialogMethod; | 134 | availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod); |
135 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 135 | availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); |
136 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 136 | availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); |
137 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; | 137 | availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); |
138 | |||
139 | // Agent management | ||
140 | availableMethods["admin_teleport_agent"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcTeleportAgentMethod); | ||
141 | |||
138 | // User management | 142 | // User management |
139 | availableMethods["admin_create_user"] = XmlRpcCreateUserMethod; | 143 | availableMethods["admin_create_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); |
140 | availableMethods["admin_create_user_email"] = XmlRpcCreateUserMethod; | 144 | availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); |
141 | availableMethods["admin_exists_user"] = XmlRpcUserExistsMethod; | 145 | availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod); |
142 | availableMethods["admin_update_user"] = XmlRpcUpdateUserAccountMethod; | 146 | availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod); |
147 | |||
143 | // Region state management | 148 | // Region state management |
144 | availableMethods["admin_load_xml"] = XmlRpcLoadXMLMethod; | 149 | availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod); |
145 | availableMethods["admin_save_xml"] = XmlRpcSaveXMLMethod; | 150 | availableMethods["admin_save_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveXMLMethod); |
146 | availableMethods["admin_load_oar"] = XmlRpcLoadOARMethod; | 151 | availableMethods["admin_load_oar"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadOARMethod); |
147 | availableMethods["admin_save_oar"] = XmlRpcSaveOARMethod; | 152 | availableMethods["admin_save_oar"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveOARMethod); |
153 | |||
148 | // Estate access list management | 154 | // Estate access list management |
149 | availableMethods["admin_acl_clear"] = XmlRpcAccessListClear; | 155 | availableMethods["admin_acl_clear"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListClear); |
150 | availableMethods["admin_acl_add"] = XmlRpcAccessListAdd; | 156 | availableMethods["admin_acl_add"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListAdd); |
151 | availableMethods["admin_acl_remove"] = XmlRpcAccessListRemove; | 157 | availableMethods["admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove); |
152 | availableMethods["admin_acl_list"] = XmlRpcAccessListList; | 158 | availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList); |
153 | 159 | ||
154 | // Either enable full remote functionality or just selected features | 160 | // Either enable full remote functionality or just selected features |
155 | string enabledMethods = m_config.GetString("enabled_methods", "all"); | 161 | string enabledMethods = m_config.GetString("enabled_methods", "all"); |
@@ -159,7 +165,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
159 | // If you just leave the option out! | 165 | // If you just leave the option out! |
160 | // | 166 | // |
161 | if (!String.IsNullOrEmpty(enabledMethods)) | 167 | if (!String.IsNullOrEmpty(enabledMethods)) |
162 | availableMethods["admin_console_command"] = XmlRpcConsoleCommandMethod; | 168 | availableMethods["admin_console_command"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcConsoleCommandMethod); |
163 | 169 | ||
164 | // The assumption here is that simply enabling Remote Admin as before will produce the same | 170 | // The assumption here is that simply enabling Remote Admin as before will produce the same |
165 | // behavior - enable all methods unless the whitelist is in place for backward-compatibility. | 171 | // behavior - enable all methods unless the whitelist is in place for backward-compatibility. |
@@ -193,34 +199,67 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
193 | } | 199 | } |
194 | } | 200 | } |
195 | 201 | ||
196 | private void FailIfRemoteAdminNotAllowed(string password, string check_ip_address) | 202 | /// <summary> |
203 | /// Invoke an XmlRpc method with the standard actions (password check, etc.) | ||
204 | /// </summary> | ||
205 | /// <param name="method"></param> | ||
206 | private XmlRpcResponse InvokeXmlRpcMethod( | ||
207 | XmlRpcRequest request, IPEndPoint remoteClient, Action<XmlRpcRequest, XmlRpcResponse, IPEndPoint> method) | ||
208 | { | ||
209 | XmlRpcResponse response = new XmlRpcResponse(); | ||
210 | Hashtable responseData = new Hashtable(); | ||
211 | response.Value = responseData; | ||
212 | |||
213 | try | ||
214 | { | ||
215 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
216 | |||
217 | m_log.Info("[RADMIN]: Request to restart Region."); | ||
218 | CheckStringParameters(requestData, responseData, new string[] {"password"}); | ||
219 | |||
220 | FailIfRemoteAdminNotAllowed((string)requestData["password"], responseData, remoteClient.Address.ToString()); | ||
221 | |||
222 | method(request, response, remoteClient); | ||
223 | } | ||
224 | catch (Exception e) | ||
225 | { | ||
226 | m_log.ErrorFormat( | ||
227 | "[RADMIN]: Method {0} failed. Exception {1}{2}", request.MethodName, e.Message, e.StackTrace); | ||
228 | |||
229 | responseData["success"] = false; | ||
230 | responseData["error"] = e.Message; | ||
231 | } | ||
232 | |||
233 | return response; | ||
234 | } | ||
235 | |||
236 | private void FailIfRemoteAdminNotAllowed(string password, Hashtable responseData, string check_ip_address) | ||
197 | { | 237 | { |
198 | if (m_accessIP.Count > 0 && !m_accessIP.Contains(check_ip_address)) | 238 | if (m_accessIP.Count > 0 && !m_accessIP.Contains(check_ip_address)) |
199 | { | 239 | { |
200 | m_log.WarnFormat("[RADMIN]: Unauthorized acess blocked from IP {0}", check_ip_address); | 240 | m_log.WarnFormat("[RADMIN]: Unauthorized access blocked from IP {0}", check_ip_address); |
241 | responseData["accepted"] = false; | ||
201 | throw new Exception("not authorized"); | 242 | throw new Exception("not authorized"); |
202 | } | 243 | } |
203 | 244 | ||
204 | if (m_requiredPassword != String.Empty && password != m_requiredPassword) | 245 | if (m_requiredPassword != String.Empty && password != m_requiredPassword) |
205 | { | 246 | { |
206 | m_log.WarnFormat("[RADMIN]: Wrong password, blocked access from IP {0}", check_ip_address); | 247 | m_log.WarnFormat("[RADMIN]: Wrong password, blocked access from IP {0}", check_ip_address); |
248 | responseData["accepted"] = false; | ||
207 | throw new Exception("wrong password"); | 249 | throw new Exception("wrong password"); |
208 | } | 250 | } |
209 | } | 251 | } |
210 | 252 | ||
211 | public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 253 | private void XmlRpcRestartMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
212 | { | 254 | { |
213 | XmlRpcResponse response = new XmlRpcResponse(); | 255 | Hashtable responseData = (Hashtable)response.Value; |
214 | Hashtable responseData = new Hashtable(); | 256 | Hashtable requestData = (Hashtable)request.Params[0]; |
215 | 257 | ||
216 | try | 258 | try |
217 | { | 259 | { |
218 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
219 | |||
220 | m_log.Info("[RADMIN]: Request to restart Region."); | 260 | m_log.Info("[RADMIN]: Request to restart Region."); |
221 | CheckStringParameters(request, new string[] {"password", "regionID"}); | ||
222 | 261 | ||
223 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 262 | CheckStringParameters(requestData, responseData, new string[] {"regionID"}); |
224 | 263 | ||
225 | UUID regionID = new UUID((string) requestData["regionID"]); | 264 | UUID regionID = new UUID((string) requestData["regionID"]); |
226 | 265 | ||
@@ -231,6 +270,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
231 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) | 270 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) |
232 | throw new Exception("region not found"); | 271 | throw new Exception("region not found"); |
233 | 272 | ||
273 | responseData["rebooting"] = true; | ||
274 | |||
234 | string message; | 275 | string message; |
235 | List<int> times = new List<int>(); | 276 | List<int> times = new List<int>(); |
236 | 277 | ||
@@ -269,78 +310,51 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
269 | notice = false; | 310 | notice = false; |
270 | } | 311 | } |
271 | 312 | ||
272 | responseData["rebooting"] = true; | ||
273 | |||
274 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 313 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); |
275 | if (restartModule != null) | 314 | if (restartModule != null) |
276 | { | 315 | { |
277 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); | 316 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); |
278 | responseData["success"] = true; | 317 | responseData["success"] = true; |
279 | } | 318 | } |
280 | |||
281 | response.Value = responseData; | ||
282 | } | 319 | } |
283 | catch (Exception e) | 320 | catch (Exception e) |
284 | { | 321 | { |
285 | m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0} {1}", e.Message, e.StackTrace); | 322 | // m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0} {1}", e.Message, e.StackTrace); |
286 | responseData["accepted"] = false; | ||
287 | responseData["success"] = false; | ||
288 | responseData["rebooting"] = false; | 323 | responseData["rebooting"] = false; |
289 | responseData["error"] = e.Message; | 324 | |
290 | response.Value = responseData; | 325 | throw e; |
291 | } | 326 | } |
292 | 327 | ||
293 | m_log.Info("[RADMIN]: Restart Region request complete"); | 328 | m_log.Info("[RADMIN]: Restart Region request complete"); |
294 | return response; | ||
295 | } | 329 | } |
296 | 330 | ||
297 | public XmlRpcResponse XmlRpcAlertMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 331 | private void XmlRpcAlertMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
298 | { | 332 | { |
299 | XmlRpcResponse response = new XmlRpcResponse(); | ||
300 | Hashtable responseData = new Hashtable(); | ||
301 | |||
302 | m_log.Info("[RADMIN]: Alert request started"); | 333 | m_log.Info("[RADMIN]: Alert request started"); |
303 | 334 | ||
304 | try | 335 | Hashtable responseData = (Hashtable)response.Value; |
305 | { | 336 | Hashtable requestData = (Hashtable)request.Params[0]; |
306 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
307 | |||
308 | CheckStringParameters(request, new string[] {"password", "message"}); | ||
309 | |||
310 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
311 | 337 | ||
312 | string message = (string) requestData["message"]; | 338 | string message = (string) requestData["message"]; |
313 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | 339 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); |
314 | 340 | ||
315 | responseData["accepted"] = true; | 341 | responseData["accepted"] = true; |
316 | responseData["success"] = true; | 342 | responseData["success"] = true; |
317 | response.Value = responseData; | ||
318 | 343 | ||
319 | m_application.SceneManager.ForEachScene( | 344 | m_application.SceneManager.ForEachScene( |
320 | delegate(Scene scene) | 345 | delegate(Scene scene) |
321 | { | 346 | { |
322 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 347 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
323 | if (dialogModule != null) | 348 | if (dialogModule != null) |
324 | dialogModule.SendGeneralAlert(message); | 349 | dialogModule.SendGeneralAlert(message); |
325 | }); | 350 | }); |
326 | } | ||
327 | catch (Exception e) | ||
328 | { | ||
329 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message, e.StackTrace); | ||
330 | |||
331 | responseData["accepted"] = false; | ||
332 | responseData["success"] = false; | ||
333 | responseData["error"] = e.Message; | ||
334 | response.Value = responseData; | ||
335 | } | ||
336 | 351 | ||
337 | m_log.Info("[RADMIN]: Alert request complete"); | 352 | m_log.Info("[RADMIN]: Alert request complete"); |
338 | return response; | ||
339 | } | 353 | } |
340 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 354 | |
355 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
341 | { | 356 | { |
342 | XmlRpcResponse response = new XmlRpcResponse(); | 357 | Hashtable responseData = (Hashtable)response.Value; |
343 | Hashtable responseData = new Hashtable(); | ||
344 | 358 | ||
345 | m_log.Info("[RADMIN]: Dialog request started"); | 359 | m_log.Info("[RADMIN]: Dialog request started"); |
346 | 360 | ||
@@ -348,19 +362,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
348 | { | 362 | { |
349 | Hashtable requestData = (Hashtable)request.Params[0]; | 363 | Hashtable requestData = (Hashtable)request.Params[0]; |
350 | 364 | ||
351 | CheckStringParameters(request, new string[] { "password", "from", "message" }); | ||
352 | |||
353 | if (m_requiredPassword != String.Empty && | ||
354 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
355 | throw new Exception("wrong password"); | ||
356 | |||
357 | string message = (string)requestData["message"]; | 365 | string message = (string)requestData["message"]; |
358 | string fromuuid = (string)requestData["from"]; | 366 | string fromuuid = (string)requestData["from"]; |
359 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | 367 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); |
360 | 368 | ||
361 | responseData["accepted"] = true; | 369 | responseData["accepted"] = true; |
362 | responseData["success"] = true; | 370 | responseData["success"] = true; |
363 | response.Value = responseData; | ||
364 | 371 | ||
365 | m_application.SceneManager.ForEachScene( | 372 | m_application.SceneManager.ForEachScene( |
366 | delegate(Scene scene) | 373 | delegate(Scene scene) |
@@ -378,197 +385,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
378 | responseData["accepted"] = false; | 385 | responseData["accepted"] = false; |
379 | responseData["success"] = false; | 386 | responseData["success"] = false; |
380 | responseData["error"] = e.Message; | 387 | responseData["error"] = e.Message; |
381 | response.Value = responseData; | ||
382 | } | 388 | } |
383 | 389 | ||
384 | m_log.Info("[RADMIN]: Alert request complete"); | 390 | m_log.Info("[RADMIN]: Alert request complete"); |
385 | return response; | ||
386 | } | 391 | } |
387 | 392 | ||
388 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 393 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
389 | { | 394 | { |
390 | XmlRpcResponse response = new XmlRpcResponse(); | ||
391 | Hashtable responseData = new Hashtable(); | ||
392 | |||
393 | m_log.Info("[RADMIN]: Load height maps request started"); | 395 | m_log.Info("[RADMIN]: Load height maps request started"); |
394 | 396 | ||
395 | try | 397 | Hashtable responseData = (Hashtable)response.Value; |
396 | { | 398 | Hashtable requestData = (Hashtable)request.Params[0]; |
397 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
398 | |||
399 | m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request); | ||
400 | // foreach (string k in requestData.Keys) | ||
401 | // { | ||
402 | // m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}", | ||
403 | // k, (string)requestData[k], ((string)requestData[k]).Length); | ||
404 | // } | ||
405 | 399 | ||
406 | CheckStringParameters(request, new string[] {"password", "filename", "regionid"}); | 400 | // m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request); |
401 | // foreach (string k in requestData.Keys) | ||
402 | // { | ||
403 | // m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}", | ||
404 | // k, (string)requestData[k], ((string)requestData[k]).Length); | ||
405 | // } | ||
407 | 406 | ||
408 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 407 | CheckStringParameters(requestData, responseData, new string[] {"filename", "regionid"}); |
409 | 408 | ||
410 | string file = (string) requestData["filename"]; | 409 | string file = (string) requestData["filename"]; |
411 | UUID regionID = (UUID) (string) requestData["regionid"]; | 410 | UUID regionID = (UUID) (string) requestData["regionid"]; |
412 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); | 411 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); |
413 | 412 | ||
414 | responseData["accepted"] = true; | 413 | responseData["accepted"] = true; |
415 | 414 | ||
416 | LoadHeightmap(file, regionID); | 415 | LoadHeightmap(file, regionID); |
417 | 416 | ||
418 | responseData["success"] = false; | 417 | responseData["success"] = true; |
419 | |||
420 | response.Value = responseData; | ||
421 | } | ||
422 | catch (Exception e) | ||
423 | { | ||
424 | m_log.ErrorFormat("[RADMIN]: Terrain Loading: failed: {0} {1}", e.Message, e.StackTrace); | ||
425 | |||
426 | responseData["success"] = false; | ||
427 | responseData["error"] = e.Message; | ||
428 | } | ||
429 | 418 | ||
430 | m_log.Info("[RADMIN]: Load height maps request complete"); | 419 | m_log.Info("[RADMIN]: Load height maps request complete"); |
431 | |||
432 | return response; | ||
433 | } | 420 | } |
434 | 421 | ||
435 | public XmlRpcResponse XmlRpcSaveHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 422 | private void XmlRpcSaveHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
436 | { | 423 | { |
437 | XmlRpcResponse response = new XmlRpcResponse(); | ||
438 | Hashtable responseData = new Hashtable(); | ||
439 | |||
440 | m_log.Info("[RADMIN]: Save height maps request started"); | 424 | m_log.Info("[RADMIN]: Save height maps request started"); |
441 | 425 | ||
442 | try | 426 | Hashtable responseData = (Hashtable)response.Value; |
443 | { | 427 | Hashtable requestData = (Hashtable)request.Params[0]; |
444 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
445 | |||
446 | m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); | ||
447 | 428 | ||
448 | CheckStringParameters(request, new string[] { "password", "filename", "regionid" }); | 429 | // m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString()); |
449 | 430 | ||
450 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 431 | CheckStringParameters(requestData, responseData, new string[] { "filename", "regionid" }); |
451 | 432 | ||
452 | string file = (string)requestData["filename"]; | 433 | string file = (string)requestData["filename"]; |
453 | UUID regionID = (UUID)(string)requestData["regionid"]; | 434 | UUID regionID = (UUID)(string)requestData["regionid"]; |
454 | m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); | 435 | m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file); |
455 | |||
456 | responseData["accepted"] = true; | ||
457 | 436 | ||
458 | Scene region = null; | 437 | responseData["accepted"] = true; |
459 | 438 | ||
460 | if (!m_application.SceneManager.TryGetScene(regionID, out region)) | 439 | Scene region = null; |
461 | throw new Exception("1: unable to get a scene with that name"); | ||
462 | |||
463 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); | ||
464 | if (null == terrainModule) throw new Exception("terrain module not available"); | ||
465 | |||
466 | terrainModule.SaveToFile(file); | ||
467 | 440 | ||
468 | responseData["success"] = false; | 441 | if (!m_application.SceneManager.TryGetScene(regionID, out region)) |
442 | throw new Exception("1: unable to get a scene with that name"); | ||
469 | 443 | ||
470 | response.Value = responseData; | 444 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); |
471 | } | 445 | if (null == terrainModule) throw new Exception("terrain module not available"); |
472 | catch (Exception e) | ||
473 | { | ||
474 | m_log.ErrorFormat("[RADMIN]: Terrain Saving: failed: {0}", e.Message); | ||
475 | m_log.DebugFormat("[RADMIN]: Terrain Saving: failed: {0}", e.ToString()); | ||
476 | 446 | ||
477 | responseData["success"] = false; | 447 | terrainModule.SaveToFile(file); |
478 | responseData["error"] = e.Message; | ||
479 | 448 | ||
480 | } | 449 | responseData["success"] = true; |
481 | 450 | ||
482 | m_log.Info("[RADMIN]: Save height maps request complete"); | 451 | m_log.Info("[RADMIN]: Save height maps request complete"); |
483 | |||
484 | return response; | ||
485 | } | 452 | } |
486 | 453 | ||
487 | public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 454 | private void XmlRpcShutdownMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
488 | { | 455 | { |
489 | m_log.Info("[RADMIN]: Received Shutdown Administrator Request"); | 456 | m_log.Info("[RADMIN]: Received Shutdown Administrator Request"); |
490 | 457 | ||
491 | XmlRpcResponse response = new XmlRpcResponse(); | 458 | Hashtable responseData = (Hashtable)response.Value; |
492 | Hashtable responseData = new Hashtable(); | 459 | Hashtable requestData = (Hashtable)request.Params[0]; |
493 | 460 | ||
494 | try | 461 | responseData["accepted"] = true; |
495 | { | 462 | response.Value = responseData; |
496 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
497 | 463 | ||
498 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 464 | int timeout = 2000; |
465 | string message; | ||
499 | 466 | ||
500 | responseData["accepted"] = true; | 467 | if (requestData.ContainsKey("shutdown") |
501 | response.Value = responseData; | 468 | && ((string) requestData["shutdown"] == "delayed") |
469 | && requestData.ContainsKey("milliseconds")) | ||
470 | { | ||
471 | timeout = Int32.Parse(requestData["milliseconds"].ToString()); | ||
502 | 472 | ||
503 | int timeout = 2000; | 473 | message |
504 | string message; | 474 | = "Region is going down in " + ((int) (timeout/1000)).ToString() |
475 | + " second(s). Please save what you are doing and log out."; | ||
476 | } | ||
477 | else | ||
478 | { | ||
479 | message = "Region is going down now."; | ||
480 | } | ||
505 | 481 | ||
506 | if (requestData.ContainsKey("shutdown") | 482 | if (requestData.ContainsKey("noticetype") |
507 | && ((string) requestData["shutdown"] == "delayed") | 483 | && ((string) requestData["noticetype"] == "dialog")) |
508 | && requestData.ContainsKey("milliseconds")) | 484 | { |
509 | { | 485 | m_application.SceneManager.ForEachScene( |
510 | timeout = Int32.Parse(requestData["milliseconds"].ToString()); | ||
511 | 486 | ||
512 | message | 487 | delegate(Scene scene) |
513 | = "Region is going down in " + ((int) (timeout/1000)).ToString() | ||
514 | + " second(s). Please save what you are doing and log out."; | ||
515 | } | ||
516 | else | ||
517 | { | 488 | { |
518 | message = "Region is going down now."; | 489 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
519 | } | 490 | if (dialogModule != null) |
520 | 491 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | |
521 | if (requestData.ContainsKey("noticetype") | 492 | }); |
522 | && ((string) requestData["noticetype"] == "dialog")) | 493 | } |
494 | else | ||
495 | { | ||
496 | if (!requestData.ContainsKey("noticetype") | ||
497 | || ((string)requestData["noticetype"] != "none")) | ||
523 | { | 498 | { |
524 | m_application.SceneManager.ForEachScene( | 499 | m_application.SceneManager.ForEachScene( |
525 | delegate(Scene scene) | 500 | delegate(Scene scene) |
526 | { | ||
527 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
528 | if (dialogModule != null) | ||
529 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
530 | }); | ||
531 | } | ||
532 | else | ||
533 | { | ||
534 | if (!requestData.ContainsKey("noticetype") | ||
535 | || ((string)requestData["noticetype"] != "none")) | ||
536 | { | 501 | { |
537 | m_application.SceneManager.ForEachScene( | 502 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
538 | delegate(Scene scene) | 503 | if (dialogModule != null) |
539 | { | 504 | dialogModule.SendGeneralAlert(message); |
540 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 505 | }); |
541 | if (dialogModule != null) | ||
542 | dialogModule.SendGeneralAlert(message); | ||
543 | }); | ||
544 | } | ||
545 | } | ||
546 | |||
547 | |||
548 | |||
549 | // Perform shutdown | ||
550 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | ||
551 | shutdownTimer.AutoReset = false; | ||
552 | shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); | ||
553 | lock (shutdownTimer) | ||
554 | { | ||
555 | shutdownTimer.Start(); | ||
556 | } | 506 | } |
557 | |||
558 | responseData["success"] = true; | ||
559 | } | 507 | } |
560 | catch (Exception e) | ||
561 | { | ||
562 | m_log.ErrorFormat("[RADMIN]: Shutdown: failed: {0} {1}", e.Message, e.StackTrace); | ||
563 | |||
564 | responseData["accepted"] = false; | ||
565 | responseData["error"] = e.Message; | ||
566 | 508 | ||
567 | response.Value = responseData; | 509 | // Perform shutdown |
510 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | ||
511 | shutdownTimer.AutoReset = false; | ||
512 | shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); | ||
513 | lock (shutdownTimer) | ||
514 | { | ||
515 | shutdownTimer.Start(); | ||
568 | } | 516 | } |
517 | |||
518 | responseData["success"] = true; | ||
569 | 519 | ||
570 | m_log.Info("[RADMIN]: Shutdown Administrator Request complete"); | 520 | m_log.Info("[RADMIN]: Shutdown Administrator Request complete"); |
571 | return response; | ||
572 | } | 521 | } |
573 | 522 | ||
574 | private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) | 523 | private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) |
@@ -639,12 +588,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
639 | /// <description>name of the newly created region</description></item> | 588 | /// <description>name of the newly created region</description></item> |
640 | /// </list> | 589 | /// </list> |
641 | /// </remarks> | 590 | /// </remarks> |
642 | public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 591 | private void XmlRpcCreateRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
643 | { | 592 | { |
644 | m_log.Info("[RADMIN]: CreateRegion: new request"); | 593 | m_log.Info("[RADMIN]: CreateRegion: new request"); |
645 | 594 | ||
646 | XmlRpcResponse response = new XmlRpcResponse(); | 595 | Hashtable responseData = (Hashtable)response.Value; |
647 | Hashtable responseData = new Hashtable(); | 596 | Hashtable requestData = (Hashtable)request.Params[0]; |
648 | 597 | ||
649 | lock (m_requestLock) | 598 | lock (m_requestLock) |
650 | { | 599 | { |
@@ -652,255 +601,235 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
652 | bool m_enableVoiceForNewRegions = m_config.GetBoolean("create_region_enable_voice", false); | 601 | bool m_enableVoiceForNewRegions = m_config.GetBoolean("create_region_enable_voice", false); |
653 | bool m_publicAccess = m_config.GetBoolean("create_region_public", true); | 602 | bool m_publicAccess = m_config.GetBoolean("create_region_public", true); |
654 | 603 | ||
655 | try | 604 | CheckStringParameters(requestData, responseData, new string[] |
605 | { | ||
606 | "region_name", | ||
607 | "listen_ip", "external_address", | ||
608 | "estate_name" | ||
609 | }); | ||
610 | CheckIntegerParams(requestData, responseData, new string[] {"region_x", "region_y", "listen_port"}); | ||
611 | |||
612 | // check whether we still have space left (iff we are using limits) | ||
613 | if (m_regionLimit != 0 && m_application.SceneManager.Scenes.Count >= m_regionLimit) | ||
614 | throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", | ||
615 | m_regionLimit)); | ||
616 | // extract or generate region ID now | ||
617 | Scene scene = null; | ||
618 | UUID regionID = UUID.Zero; | ||
619 | if (requestData.ContainsKey("region_id") && | ||
620 | !String.IsNullOrEmpty((string) requestData["region_id"])) | ||
656 | { | 621 | { |
657 | Hashtable requestData = (Hashtable) request.Params[0]; | 622 | regionID = (UUID) (string) requestData["region_id"]; |
658 | 623 | if (m_application.SceneManager.TryGetScene(regionID, out scene)) | |
659 | CheckStringParameters(request, new string[] | 624 | throw new Exception( |
660 | { | 625 | String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", |
661 | "password", | 626 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, |
662 | "region_name", | 627 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); |
663 | "listen_ip", "external_address", | 628 | } |
664 | "estate_name" | 629 | else |
665 | }); | 630 | { |
666 | CheckIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); | 631 | regionID = UUID.Random(); |
667 | 632 | m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); | |
668 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 633 | } |
669 | 634 | ||
670 | // check whether we still have space left (iff we are using limits) | 635 | // create volatile or persistent region info |
671 | if (m_regionLimit != 0 && m_application.SceneManager.Scenes.Count >= m_regionLimit) | 636 | RegionInfo region = new RegionInfo(); |
672 | throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", | 637 | |
673 | m_regionLimit)); | 638 | region.RegionID = regionID; |
674 | // extract or generate region ID now | 639 | region.originRegionID = regionID; |
675 | Scene scene = null; | 640 | region.RegionName = (string) requestData["region_name"]; |
676 | UUID regionID = UUID.Zero; | 641 | region.RegionLocX = Convert.ToUInt32(requestData["region_x"]); |
677 | if (requestData.ContainsKey("region_id") && | 642 | region.RegionLocY = Convert.ToUInt32(requestData["region_y"]); |
678 | !String.IsNullOrEmpty((string) requestData["region_id"])) | 643 | |
644 | // check for collisions: region name, region UUID, | ||
645 | // region location | ||
646 | if (m_application.SceneManager.TryGetScene(region.RegionName, out scene)) | ||
647 | throw new Exception( | ||
648 | String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", | ||
649 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
650 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
651 | |||
652 | if (m_application.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) | ||
653 | throw new Exception( | ||
654 | String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", | ||
655 | region.RegionLocX, region.RegionLocY, | ||
656 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
657 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
658 | |||
659 | region.InternalEndPoint = | ||
660 | new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); | ||
661 | |||
662 | region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); | ||
663 | if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); | ||
664 | if (m_application.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) | ||
665 | throw new Exception( | ||
666 | String.Format( | ||
667 | "region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", | ||
668 | region.InternalEndPoint.Address, | ||
669 | region.InternalEndPoint.Port, | ||
670 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
671 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
672 | |||
673 | region.ExternalHostName = (string) requestData["external_address"]; | ||
674 | |||
675 | bool persist = Convert.ToBoolean((string) requestData["persist"]); | ||
676 | if (persist) | ||
677 | { | ||
678 | // default place for region configuration files is in the | ||
679 | // Regions directory of the config dir (aka /bin) | ||
680 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); | ||
681 | try | ||
679 | { | 682 | { |
680 | regionID = (UUID) (string) requestData["region_id"]; | 683 | // OpenSim.ini can specify a different regions dir |
681 | if (m_application.SceneManager.TryGetScene(regionID, out scene)) | 684 | IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; |
682 | throw new Exception( | 685 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); |
683 | String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", | ||
684 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
685 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
686 | } | 686 | } |
687 | else | 687 | catch (Exception) |
688 | { | 688 | { |
689 | regionID = UUID.Random(); | 689 | // No INI setting recorded. |
690 | m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); | ||
691 | } | 690 | } |
692 | 691 | ||
693 | // create volatile or persistent region info | 692 | string regionIniPath; |
694 | RegionInfo region = new RegionInfo(); | 693 | |
695 | 694 | if (requestData.Contains("region_file")) | |
696 | region.RegionID = regionID; | ||
697 | region.originRegionID = regionID; | ||
698 | region.RegionName = (string) requestData["region_name"]; | ||
699 | region.RegionLocX = Convert.ToUInt32(requestData["region_x"]); | ||
700 | region.RegionLocY = Convert.ToUInt32(requestData["region_y"]); | ||
701 | |||
702 | // check for collisions: region name, region UUID, | ||
703 | // region location | ||
704 | if (m_application.SceneManager.TryGetScene(region.RegionName, out scene)) | ||
705 | throw new Exception( | ||
706 | String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", | ||
707 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
708 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
709 | |||
710 | if (m_application.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) | ||
711 | throw new Exception( | ||
712 | String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", | ||
713 | region.RegionLocX, region.RegionLocY, | ||
714 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
715 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
716 | |||
717 | region.InternalEndPoint = | ||
718 | new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); | ||
719 | |||
720 | region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); | ||
721 | if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); | ||
722 | if (m_application.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) | ||
723 | throw new Exception( | ||
724 | String.Format( | ||
725 | "region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", | ||
726 | region.InternalEndPoint.Address, | ||
727 | region.InternalEndPoint.Port, | ||
728 | scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, | ||
729 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); | ||
730 | |||
731 | region.ExternalHostName = (string) requestData["external_address"]; | ||
732 | |||
733 | bool persist = Convert.ToBoolean((string) requestData["persist"]); | ||
734 | if (persist) | ||
735 | { | 695 | { |
736 | // default place for region configuration files is in the | 696 | // Make sure that the file to be created is in a subdirectory of the region storage directory. |
737 | // Regions directory of the config dir (aka /bin) | 697 | string requestedFilePath = Path.Combine(regionConfigPath, (string) requestData["region_file"]); |
738 | string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); | 698 | string requestedDirectory = Path.GetDirectoryName(Path.GetFullPath(requestedFilePath)); |
739 | try | 699 | if (requestedDirectory.StartsWith(Path.GetFullPath(regionConfigPath))) |
740 | { | 700 | regionIniPath = requestedFilePath; |
741 | // OpenSim.ini can specify a different regions dir | ||
742 | IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; | ||
743 | regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); | ||
744 | } | ||
745 | catch (Exception) | ||
746 | { | ||
747 | // No INI setting recorded. | ||
748 | } | ||
749 | |||
750 | string regionIniPath; | ||
751 | |||
752 | if (requestData.Contains("region_file")) | ||
753 | { | ||
754 | // Make sure that the file to be created is in a subdirectory of the region storage directory. | ||
755 | string requestedFilePath = Path.Combine(regionConfigPath, (string) requestData["region_file"]); | ||
756 | string requestedDirectory = Path.GetDirectoryName(Path.GetFullPath(requestedFilePath)); | ||
757 | if (requestedDirectory.StartsWith(Path.GetFullPath(regionConfigPath))) | ||
758 | regionIniPath = requestedFilePath; | ||
759 | else | ||
760 | throw new Exception("Invalid location for region file."); | ||
761 | } | ||
762 | else | 701 | else |
763 | { | 702 | throw new Exception("Invalid location for region file."); |
764 | regionIniPath = Path.Combine(regionConfigPath, | ||
765 | String.Format( | ||
766 | m_config.GetString("region_file_template", | ||
767 | "{0}x{1}-{2}.ini"), | ||
768 | region.RegionLocX.ToString(), | ||
769 | region.RegionLocY.ToString(), | ||
770 | regionID.ToString(), | ||
771 | region.InternalEndPoint.Port.ToString(), | ||
772 | region.RegionName.Replace(" ", "_").Replace(":", "_"). | ||
773 | Replace("/", "_"))); | ||
774 | } | ||
775 | |||
776 | m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", | ||
777 | region.RegionID, regionIniPath); | ||
778 | region.SaveRegionToFile("dynamic region", regionIniPath); | ||
779 | } | 703 | } |
780 | else | 704 | else |
781 | { | 705 | { |
782 | region.Persistent = false; | 706 | regionIniPath = Path.Combine(regionConfigPath, |
707 | String.Format( | ||
708 | m_config.GetString("region_file_template", | ||
709 | "{0}x{1}-{2}.ini"), | ||
710 | region.RegionLocX.ToString(), | ||
711 | region.RegionLocY.ToString(), | ||
712 | regionID.ToString(), | ||
713 | region.InternalEndPoint.Port.ToString(), | ||
714 | region.RegionName.Replace(" ", "_").Replace(":", "_"). | ||
715 | Replace("/", "_"))); | ||
783 | } | 716 | } |
784 | |||
785 | // Set the estate | ||
786 | 717 | ||
787 | // Check for an existing estate | 718 | m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", |
788 | List<int> estateIDs = m_application.EstateDataService.GetEstates((string) requestData["estate_name"]); | 719 | region.RegionID, regionIniPath); |
789 | if (estateIDs.Count < 1) | 720 | region.SaveRegionToFile("dynamic region", regionIniPath); |
721 | } | ||
722 | else | ||
723 | { | ||
724 | region.Persistent = false; | ||
725 | } | ||
726 | |||
727 | // Set the estate | ||
728 | |||
729 | // Check for an existing estate | ||
730 | List<int> estateIDs = m_application.EstateDataService.GetEstates((string) requestData["estate_name"]); | ||
731 | if (estateIDs.Count < 1) | ||
732 | { | ||
733 | UUID userID = UUID.Zero; | ||
734 | if (requestData.ContainsKey("estate_owner_uuid")) | ||
790 | { | 735 | { |
791 | UUID userID = UUID.Zero; | 736 | // ok, client wants us to use an explicit UUID |
792 | if (requestData.ContainsKey("estate_owner_uuid")) | 737 | // regardless of what the avatar name provided |
793 | { | 738 | userID = new UUID((string) requestData["estate_owner_uuid"]); |
794 | // ok, client wants us to use an explicit UUID | ||
795 | // regardless of what the avatar name provided | ||
796 | userID = new UUID((string) requestData["estate_owner_uuid"]); | ||
797 | |||
798 | // Check that the specified user exists | ||
799 | Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene; | ||
800 | IUserAccountService accountService = currentOrFirst.UserAccountService; | ||
801 | UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, userID); | ||
802 | |||
803 | if (user == null) | ||
804 | throw new Exception("Specified user was not found."); | ||
805 | } | ||
806 | else if (requestData.ContainsKey("estate_owner_first") & requestData.ContainsKey("estate_owner_last")) | ||
807 | { | ||
808 | // We need to look up the UUID for the avatar with the provided name. | ||
809 | string ownerFirst = (string) requestData["estate_owner_first"]; | ||
810 | string ownerLast = (string) requestData["estate_owner_last"]; | ||
811 | |||
812 | Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene; | ||
813 | IUserAccountService accountService = currentOrFirst.UserAccountService; | ||
814 | UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, | ||
815 | ownerFirst, ownerLast); | ||
816 | |||
817 | // Check that the specified user exists | ||
818 | if (user == null) | ||
819 | throw new Exception("Specified user was not found."); | ||
820 | |||
821 | userID = user.PrincipalID; | ||
822 | } | ||
823 | else | ||
824 | { | ||
825 | throw new Exception("Estate owner details not provided."); | ||
826 | } | ||
827 | 739 | ||
828 | // Create a new estate with the name provided | 740 | // Check that the specified user exists |
829 | region.EstateSettings = m_application.EstateDataService.CreateNewEstate(); | 741 | Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene; |
830 | 742 | IUserAccountService accountService = currentOrFirst.UserAccountService; | |
831 | region.EstateSettings.EstateName = (string) requestData["estate_name"]; | 743 | UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, userID); |
832 | region.EstateSettings.EstateOwner = userID; | 744 | |
833 | // Persistence does not seem to effect the need to save a new estate | 745 | if (user == null) |
834 | region.EstateSettings.Save(); | 746 | throw new Exception("Specified user was not found."); |
835 | 747 | } | |
836 | if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID)) | 748 | else if (requestData.ContainsKey("estate_owner_first") & requestData.ContainsKey("estate_owner_last")) |
837 | throw new Exception("Failed to join estate."); | 749 | { |
750 | // We need to look up the UUID for the avatar with the provided name. | ||
751 | string ownerFirst = (string) requestData["estate_owner_first"]; | ||
752 | string ownerLast = (string) requestData["estate_owner_last"]; | ||
753 | |||
754 | Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene; | ||
755 | IUserAccountService accountService = currentOrFirst.UserAccountService; | ||
756 | UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, | ||
757 | ownerFirst, ownerLast); | ||
758 | |||
759 | // Check that the specified user exists | ||
760 | if (user == null) | ||
761 | throw new Exception("Specified user was not found."); | ||
762 | |||
763 | userID = user.PrincipalID; | ||
838 | } | 764 | } |
839 | else | 765 | else |
840 | { | 766 | { |
841 | int estateID = estateIDs[0]; | 767 | throw new Exception("Estate owner details not provided."); |
842 | |||
843 | region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(region.RegionID, false); | ||
844 | |||
845 | if (region.EstateSettings.EstateID != estateID) | ||
846 | { | ||
847 | // The region is already part of an estate, but not the one we want. | ||
848 | region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(estateID); | ||
849 | |||
850 | if (!m_application.EstateDataService.LinkRegion(region.RegionID, estateID)) | ||
851 | throw new Exception("Failed to join estate."); | ||
852 | } | ||
853 | } | 768 | } |
854 | 769 | ||
855 | // Create the region and perform any initial initialization | 770 | // Create a new estate with the name provided |
771 | region.EstateSettings = m_application.EstateDataService.CreateNewEstate(); | ||
856 | 772 | ||
857 | IScene newScene; | 773 | region.EstateSettings.EstateName = (string) requestData["estate_name"]; |
858 | m_application.CreateRegion(region, out newScene); | 774 | region.EstateSettings.EstateOwner = userID; |
775 | // Persistence does not seem to effect the need to save a new estate | ||
776 | region.EstateSettings.Save(); | ||
859 | 777 | ||
860 | // If an access specification was provided, use it. | 778 | if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID)) |
861 | // Otherwise accept the default. | 779 | throw new Exception("Failed to join estate."); |
862 | newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess); | 780 | } |
863 | newScene.RegionInfo.EstateSettings.Save(); | 781 | else |
782 | { | ||
783 | int estateID = estateIDs[0]; | ||
784 | |||
785 | region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(region.RegionID, false); | ||
864 | 786 | ||
865 | // enable voice on newly created region if | 787 | if (region.EstateSettings.EstateID != estateID) |
866 | // requested by either the XmlRpc request or the | ||
867 | // configuration | ||
868 | if (GetBoolean(requestData, "enable_voice", m_enableVoiceForNewRegions)) | ||
869 | { | 788 | { |
870 | List<ILandObject> parcels = ((Scene)newScene).LandChannel.AllParcels(); | 789 | // The region is already part of an estate, but not the one we want. |
790 | region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(estateID); | ||
871 | 791 | ||
872 | foreach (ILandObject parcel in parcels) | 792 | if (!m_application.EstateDataService.LinkRegion(region.RegionID, estateID)) |
873 | { | 793 | throw new Exception("Failed to join estate."); |
874 | parcel.LandData.Flags |= (uint) ParcelFlags.AllowVoiceChat; | ||
875 | parcel.LandData.Flags |= (uint) ParcelFlags.UseEstateVoiceChan; | ||
876 | ((Scene)newScene).LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData); | ||
877 | } | ||
878 | } | 794 | } |
795 | } | ||
796 | |||
797 | // Create the region and perform any initial initialization | ||
879 | 798 | ||
880 | //Load Heightmap if specified to new region | 799 | IScene newScene; |
881 | if (requestData.Contains("heightmap_file")) | 800 | m_application.CreateRegion(region, out newScene); |
882 | { | ||
883 | LoadHeightmap((string)requestData["heightmap_file"], region.RegionID); | ||
884 | } | ||
885 | 801 | ||
886 | responseData["success"] = true; | 802 | // If an access specification was provided, use it. |
887 | responseData["region_name"] = region.RegionName; | 803 | // Otherwise accept the default. |
888 | responseData["region_uuid"] = region.RegionID.ToString(); | 804 | newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess); |
805 | newScene.RegionInfo.EstateSettings.Save(); | ||
889 | 806 | ||
890 | response.Value = responseData; | 807 | // enable voice on newly created region if |
891 | } | 808 | // requested by either the XmlRpc request or the |
892 | catch (Exception e) | 809 | // configuration |
810 | if (GetBoolean(requestData, "enable_voice", m_enableVoiceForNewRegions)) | ||
893 | { | 811 | { |
894 | m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0} {1}", e.Message, e.StackTrace); | 812 | List<ILandObject> parcels = ((Scene)newScene).LandChannel.AllParcels(); |
895 | 813 | ||
896 | responseData["success"] = false; | 814 | foreach (ILandObject parcel in parcels) |
897 | responseData["error"] = e.Message; | 815 | { |
816 | parcel.LandData.Flags |= (uint) ParcelFlags.AllowVoiceChat; | ||
817 | parcel.LandData.Flags |= (uint) ParcelFlags.UseEstateVoiceChan; | ||
818 | ((Scene)newScene).LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData); | ||
819 | } | ||
820 | } | ||
898 | 821 | ||
899 | response.Value = responseData; | 822 | //Load Heightmap if specified to new region |
823 | if (requestData.Contains("heightmap_file")) | ||
824 | { | ||
825 | LoadHeightmap((string)requestData["heightmap_file"], region.RegionID); | ||
900 | } | 826 | } |
901 | 827 | ||
828 | responseData["success"] = true; | ||
829 | responseData["region_name"] = region.RegionName; | ||
830 | responseData["region_uuid"] = region.RegionID.ToString(); | ||
831 | |||
902 | m_log.Info("[RADMIN]: CreateRegion: request complete"); | 832 | m_log.Info("[RADMIN]: CreateRegion: request complete"); |
903 | return response; | ||
904 | } | 833 | } |
905 | } | 834 | } |
906 | 835 | ||
@@ -930,46 +859,28 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
930 | /// <description>error message if success is false</description></item> | 859 | /// <description>error message if success is false</description></item> |
931 | /// </list> | 860 | /// </list> |
932 | /// </remarks> | 861 | /// </remarks> |
933 | public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 862 | private void XmlRpcDeleteRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
934 | { | 863 | { |
935 | m_log.Info("[RADMIN]: DeleteRegion: new request"); | 864 | m_log.Info("[RADMIN]: DeleteRegion: new request"); |
936 | 865 | ||
937 | XmlRpcResponse response = new XmlRpcResponse(); | 866 | Hashtable responseData = (Hashtable)response.Value; |
938 | Hashtable responseData = new Hashtable(); | 867 | Hashtable requestData = (Hashtable)request.Params[0]; |
939 | 868 | ||
940 | lock (m_requestLock) | 869 | lock (m_requestLock) |
941 | { | 870 | { |
942 | try | 871 | CheckStringParameters(requestData, responseData, new string[] {"region_name"}); |
943 | { | ||
944 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
945 | CheckStringParameters(request, new string[] {"password", "region_name"}); | ||
946 | |||
947 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
948 | |||
949 | Scene scene = null; | ||
950 | string regionName = (string) requestData["region_name"]; | ||
951 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | ||
952 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | ||
953 | |||
954 | m_application.RemoveRegion(scene, true); | ||
955 | 872 | ||
956 | responseData["success"] = true; | 873 | Scene scene = null; |
957 | responseData["region_name"] = regionName; | 874 | string regionName = (string) requestData["region_name"]; |
958 | 875 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | |
959 | response.Value = responseData; | 876 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); |
960 | } | ||
961 | catch (Exception e) | ||
962 | { | ||
963 | m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0} {1}", e.Message, e.StackTrace); | ||
964 | 877 | ||
965 | responseData["success"] = false; | 878 | m_application.RemoveRegion(scene, true); |
966 | responseData["error"] = e.Message; | ||
967 | 879 | ||
968 | response.Value = responseData; | 880 | responseData["success"] = true; |
969 | } | 881 | responseData["region_name"] = regionName; |
970 | 882 | ||
971 | m_log.Info("[RADMIN]: DeleteRegion: request complete"); | 883 | m_log.Info("[RADMIN]: DeleteRegion: request complete"); |
972 | return response; | ||
973 | } | 884 | } |
974 | } | 885 | } |
975 | 886 | ||
@@ -1001,69 +912,52 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1001 | /// <description>error message if success is false</description></item> | 912 | /// <description>error message if success is false</description></item> |
1002 | /// </list> | 913 | /// </list> |
1003 | /// </remarks> | 914 | /// </remarks> |
1004 | public XmlRpcResponse XmlRpcCloseRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 915 | private void XmlRpcCloseRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1005 | { | 916 | { |
1006 | m_log.Info("[RADMIN]: CloseRegion: new request"); | 917 | m_log.Info("[RADMIN]: CloseRegion: new request"); |
1007 | 918 | ||
1008 | XmlRpcResponse response = new XmlRpcResponse(); | 919 | Hashtable responseData = (Hashtable)response.Value; |
1009 | Hashtable responseData = new Hashtable(); | 920 | Hashtable requestData = (Hashtable)request.Params[0]; |
1010 | Scene scene = null; | 921 | Scene scene = null; |
1011 | 922 | ||
1012 | lock (m_requestLock) | 923 | lock (m_requestLock) |
1013 | { | 924 | { |
1014 | try | 925 | if (requestData.ContainsKey("region_id") && |
926 | !String.IsNullOrEmpty((string) requestData["region_id"])) | ||
1015 | { | 927 | { |
1016 | Hashtable requestData = (Hashtable) request.Params[0]; | 928 | // Region specified by UUID |
1017 | CheckStringParameters(request, new string[] {"password"}); | 929 | UUID regionID = (UUID) (string) requestData["region_id"]; |
930 | if (!m_application.SceneManager.TryGetScene(regionID, out scene)) | ||
931 | throw new Exception(String.Format("region \"{0}\" does not exist", regionID)); | ||
1018 | 932 | ||
1019 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 933 | m_application.CloseRegion(scene); |
1020 | |||
1021 | if (requestData.ContainsKey("region_id") && | ||
1022 | !String.IsNullOrEmpty((string) requestData["region_id"])) | ||
1023 | { | ||
1024 | // Region specified by UUID | ||
1025 | UUID regionID = (UUID) (string) requestData["region_id"]; | ||
1026 | if (!m_application.SceneManager.TryGetScene(regionID, out scene)) | ||
1027 | throw new Exception(String.Format("region \"{0}\" does not exist", regionID)); | ||
1028 | 934 | ||
1029 | m_application.CloseRegion(scene); | 935 | responseData["success"] = true; |
1030 | 936 | responseData["region_id"] = regionID; | |
1031 | responseData["success"] = true; | ||
1032 | responseData["region_id"] = regionID; | ||
1033 | |||
1034 | response.Value = responseData; | ||
1035 | } | ||
1036 | else if (requestData.ContainsKey("region_name") && | ||
1037 | !String.IsNullOrEmpty((string) requestData["region_name"])) | ||
1038 | { | ||
1039 | // Region specified by name | ||
1040 | 937 | ||
1041 | string regionName = (string) requestData["region_name"]; | 938 | response.Value = responseData; |
1042 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | 939 | } |
1043 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | 940 | else if ( |
941 | requestData.ContainsKey("region_name") | ||
942 | && !String.IsNullOrEmpty((string) requestData["region_name"])) | ||
943 | { | ||
944 | // Region specified by name | ||
1044 | 945 | ||
1045 | m_application.CloseRegion(scene); | 946 | string regionName = (string) requestData["region_name"]; |
947 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | ||
948 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | ||
1046 | 949 | ||
1047 | responseData["success"] = true; | 950 | m_application.CloseRegion(scene); |
1048 | responseData["region_name"] = regionName; | ||
1049 | 951 | ||
1050 | response.Value = responseData; | 952 | responseData["success"] = true; |
1051 | } | 953 | responseData["region_name"] = regionName; |
1052 | else | ||
1053 | throw new Exception("no region specified"); | ||
1054 | } | 954 | } |
1055 | catch (Exception e) | 955 | else |
1056 | { | 956 | { |
1057 | m_log.ErrorFormat("[RADMIN]: CloseRegion: failed {0} {1}", e.Message, e.StackTrace); | 957 | throw new Exception("no region specified"); |
1058 | |||
1059 | responseData["success"] = false; | ||
1060 | responseData["error"] = e.Message; | ||
1061 | |||
1062 | response.Value = responseData; | ||
1063 | } | 958 | } |
1064 | 959 | ||
1065 | m_log.Info("[RADMIN]: CloseRegion: request complete"); | 960 | m_log.Info("[RADMIN]: CloseRegion: request complete"); |
1066 | return response; | ||
1067 | } | 961 | } |
1068 | } | 962 | } |
1069 | 963 | ||
@@ -1099,70 +993,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1099 | /// <description>error message if success is false</description></item> | 993 | /// <description>error message if success is false</description></item> |
1100 | /// </list> | 994 | /// </list> |
1101 | /// </remarks> | 995 | /// </remarks> |
1102 | public XmlRpcResponse XmlRpcModifyRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 996 | private void XmlRpcModifyRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1103 | { | 997 | { |
1104 | m_log.Info("[RADMIN]: ModifyRegion: new request"); | 998 | m_log.Info("[RADMIN]: ModifyRegion: new request"); |
1105 | XmlRpcResponse response = new XmlRpcResponse(); | 999 | |
1106 | Hashtable responseData = new Hashtable(); | 1000 | Hashtable responseData = (Hashtable)response.Value; |
1001 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1107 | 1002 | ||
1108 | lock (m_requestLock) | 1003 | lock (m_requestLock) |
1109 | { | 1004 | { |
1110 | try | 1005 | CheckStringParameters(requestData, responseData, new string[] {"region_name"}); |
1111 | { | ||
1112 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1113 | CheckStringParameters(request, new string[] {"password", "region_name"}); | ||
1114 | 1006 | ||
1115 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 1007 | Scene scene = null; |
1008 | string regionName = (string) requestData["region_name"]; | ||
1009 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | ||
1010 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | ||
1116 | 1011 | ||
1117 | Scene scene = null; | 1012 | // Modify access |
1118 | string regionName = (string) requestData["region_name"]; | 1013 | scene.RegionInfo.EstateSettings.PublicAccess = |
1119 | if (!m_application.SceneManager.TryGetScene(regionName, out scene)) | 1014 | GetBoolean(requestData,"public", scene.RegionInfo.EstateSettings.PublicAccess); |
1120 | throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); | 1015 | if (scene.RegionInfo.Persistent) |
1016 | scene.RegionInfo.EstateSettings.Save(); | ||
1121 | 1017 | ||
1122 | // Modify access | 1018 | if (requestData.ContainsKey("enable_voice")) |
1123 | scene.RegionInfo.EstateSettings.PublicAccess = | 1019 | { |
1124 | GetBoolean(requestData,"public", scene.RegionInfo.EstateSettings.PublicAccess); | 1020 | bool enableVoice = GetBoolean(requestData, "enable_voice", true); |
1125 | if (scene.RegionInfo.Persistent) | 1021 | List<ILandObject> parcels = ((Scene)scene).LandChannel.AllParcels(); |
1126 | scene.RegionInfo.EstateSettings.Save(); | ||
1127 | 1022 | ||
1128 | if (requestData.ContainsKey("enable_voice")) | 1023 | foreach (ILandObject parcel in parcels) |
1129 | { | 1024 | { |
1130 | bool enableVoice = GetBoolean(requestData, "enable_voice", true); | 1025 | if (enableVoice) |
1131 | List<ILandObject> parcels = ((Scene)scene).LandChannel.AllParcels(); | ||
1132 | |||
1133 | foreach (ILandObject parcel in parcels) | ||
1134 | { | 1026 | { |
1135 | if (enableVoice) | 1027 | parcel.LandData.Flags |= (uint)ParcelFlags.AllowVoiceChat; |
1136 | { | 1028 | parcel.LandData.Flags |= (uint)ParcelFlags.UseEstateVoiceChan; |
1137 | parcel.LandData.Flags |= (uint)ParcelFlags.AllowVoiceChat; | ||
1138 | parcel.LandData.Flags |= (uint)ParcelFlags.UseEstateVoiceChan; | ||
1139 | } | ||
1140 | else | ||
1141 | { | ||
1142 | parcel.LandData.Flags &= ~(uint)ParcelFlags.AllowVoiceChat; | ||
1143 | parcel.LandData.Flags &= ~(uint)ParcelFlags.UseEstateVoiceChan; | ||
1144 | } | ||
1145 | scene.LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData); | ||
1146 | } | 1029 | } |
1030 | else | ||
1031 | { | ||
1032 | parcel.LandData.Flags &= ~(uint)ParcelFlags.AllowVoiceChat; | ||
1033 | parcel.LandData.Flags &= ~(uint)ParcelFlags.UseEstateVoiceChan; | ||
1034 | } | ||
1035 | scene.LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData); | ||
1147 | } | 1036 | } |
1148 | |||
1149 | responseData["success"] = true; | ||
1150 | responseData["region_name"] = regionName; | ||
1151 | |||
1152 | response.Value = responseData; | ||
1153 | } | 1037 | } |
1154 | catch (Exception e) | ||
1155 | { | ||
1156 | m_log.ErrorFormat("[RADMIN] ModifyRegion: failed {0} {1}", e.Message, e.StackTrace); | ||
1157 | 1038 | ||
1158 | responseData["success"] = false; | 1039 | responseData["success"] = true; |
1159 | responseData["error"] = e.Message; | 1040 | responseData["region_name"] = regionName; |
1160 | |||
1161 | response.Value = responseData; | ||
1162 | } | ||
1163 | 1041 | ||
1164 | m_log.Info("[RADMIN]: ModifyRegion: request complete"); | 1042 | m_log.Info("[RADMIN]: ModifyRegion: request complete"); |
1165 | return response; | ||
1166 | } | 1043 | } |
1167 | } | 1044 | } |
1168 | 1045 | ||
@@ -1204,28 +1081,24 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1204 | /// </description></item> | 1081 | /// </description></item> |
1205 | /// </list> | 1082 | /// </list> |
1206 | /// </remarks> | 1083 | /// </remarks> |
1207 | public XmlRpcResponse XmlRpcCreateUserMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 1084 | private void XmlRpcCreateUserMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1208 | { | 1085 | { |
1209 | m_log.Info("[RADMIN]: CreateUser: new request"); | 1086 | m_log.Info("[RADMIN]: CreateUser: new request"); |
1210 | 1087 | ||
1211 | XmlRpcResponse response = new XmlRpcResponse(); | 1088 | Hashtable responseData = (Hashtable)response.Value; |
1212 | Hashtable responseData = new Hashtable(); | 1089 | Hashtable requestData = (Hashtable)request.Params[0]; |
1213 | 1090 | ||
1214 | lock (m_requestLock) | 1091 | lock (m_requestLock) |
1215 | { | 1092 | { |
1216 | try | 1093 | try |
1217 | { | 1094 | { |
1218 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1219 | |||
1220 | // check completeness | 1095 | // check completeness |
1221 | CheckStringParameters(request, new string[] | 1096 | CheckStringParameters(requestData, responseData, new string[] |
1222 | { | 1097 | { |
1223 | "password", "user_firstname", | 1098 | "user_firstname", |
1224 | "user_lastname", "user_password", | 1099 | "user_lastname", "user_password", |
1225 | }); | 1100 | }); |
1226 | CheckIntegerParams(request, new string[] {"start_region_x", "start_region_y"}); | 1101 | CheckIntegerParams(requestData, responseData, new string[] {"start_region_x", "start_region_y"}); |
1227 | |||
1228 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
1229 | 1102 | ||
1230 | // do the job | 1103 | // do the job |
1231 | string firstName = (string) requestData["user_firstname"]; | 1104 | string firstName = (string) requestData["user_firstname"]; |
@@ -1252,9 +1125,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1252 | 1125 | ||
1253 | GridRegion home = scene.GridService.GetRegionByPosition(scopeID, | 1126 | GridRegion home = scene.GridService.GetRegionByPosition(scopeID, |
1254 | (int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize)); | 1127 | (int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize)); |
1255 | if (null == home) { | 1128 | if (null == home) |
1129 | { | ||
1256 | m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName); | 1130 | m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName); |
1257 | } else { | 1131 | } |
1132 | else | ||
1133 | { | ||
1258 | scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | 1134 | scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); |
1259 | m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstName, lastName); | 1135 | m_log.DebugFormat("[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstName, lastName); |
1260 | } | 1136 | } |
@@ -1266,22 +1142,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1266 | responseData["success"] = true; | 1142 | responseData["success"] = true; |
1267 | responseData["avatar_uuid"] = account.PrincipalID.ToString(); | 1143 | responseData["avatar_uuid"] = account.PrincipalID.ToString(); |
1268 | 1144 | ||
1269 | response.Value = responseData; | ||
1270 | |||
1271 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstName, lastName, account.PrincipalID); | 1145 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstName, lastName, account.PrincipalID); |
1272 | } | 1146 | } |
1273 | catch (Exception e) | 1147 | catch (Exception e) |
1274 | { | 1148 | { |
1275 | m_log.ErrorFormat("[RADMIN]: CreateUser: failed: {0} {1}", e.Message, e.StackTrace); | ||
1276 | |||
1277 | responseData["success"] = false; | ||
1278 | responseData["avatar_uuid"] = UUID.Zero.ToString(); | 1149 | responseData["avatar_uuid"] = UUID.Zero.ToString(); |
1279 | responseData["error"] = e.Message; | ||
1280 | 1150 | ||
1281 | response.Value = responseData; | 1151 | throw e; |
1282 | } | 1152 | } |
1153 | |||
1283 | m_log.Info("[RADMIN]: CreateUser: request complete"); | 1154 | m_log.Info("[RADMIN]: CreateUser: request complete"); |
1284 | return response; | ||
1285 | } | 1155 | } |
1286 | } | 1156 | } |
1287 | 1157 | ||
@@ -1317,62 +1187,43 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1317 | /// <description>error message if success is false</description></item> | 1187 | /// <description>error message if success is false</description></item> |
1318 | /// </list> | 1188 | /// </list> |
1319 | /// </remarks> | 1189 | /// </remarks> |
1320 | public XmlRpcResponse XmlRpcUserExistsMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 1190 | private void XmlRpcUserExistsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1321 | { | 1191 | { |
1322 | m_log.Info("[RADMIN]: UserExists: new request"); | 1192 | m_log.Info("[RADMIN]: UserExists: new request"); |
1323 | 1193 | ||
1324 | XmlRpcResponse response = new XmlRpcResponse(); | 1194 | Hashtable responseData = (Hashtable)response.Value; |
1325 | Hashtable responseData = new Hashtable(); | 1195 | Hashtable requestData = (Hashtable)request.Params[0]; |
1326 | 1196 | ||
1327 | try | 1197 | // check completeness |
1328 | { | 1198 | CheckStringParameters(requestData, responseData, new string[] {"user_firstname", "user_lastname"}); |
1329 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1330 | |||
1331 | // check completeness | ||
1332 | CheckStringParameters(request, new string[] {"password", "user_firstname", "user_lastname"}); | ||
1333 | 1199 | ||
1334 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | 1200 | string firstName = (string) requestData["user_firstname"]; |
1201 | string lastName = (string) requestData["user_lastname"]; | ||
1335 | 1202 | ||
1336 | string firstName = (string) requestData["user_firstname"]; | 1203 | responseData["user_firstname"] = firstName; |
1337 | string lastName = (string) requestData["user_lastname"]; | 1204 | responseData["user_lastname"] = lastName; |
1338 | 1205 | ||
1339 | responseData["user_firstname"] = firstName; | 1206 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; |
1340 | responseData["user_lastname"] = lastName; | ||
1341 | |||
1342 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
1343 | 1207 | ||
1344 | UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstName, lastName); | 1208 | UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstName, lastName); |
1345 | 1209 | ||
1346 | if (null == account) | 1210 | if (null == account) |
1347 | { | ||
1348 | responseData["success"] = false; | ||
1349 | responseData["lastlogin"] = 0; | ||
1350 | } | ||
1351 | else | ||
1352 | { | ||
1353 | GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString()); | ||
1354 | if (userInfo != null) | ||
1355 | responseData["lastlogin"] = userInfo.Login; | ||
1356 | else | ||
1357 | responseData["lastlogin"] = 0; | ||
1358 | |||
1359 | responseData["success"] = true; | ||
1360 | } | ||
1361 | |||
1362 | response.Value = responseData; | ||
1363 | } | ||
1364 | catch (Exception e) | ||
1365 | { | 1211 | { |
1366 | m_log.ErrorFormat("[RADMIN]: UserExists: failed: {0} {1}", e.Message, e.StackTrace); | ||
1367 | |||
1368 | responseData["success"] = false; | 1212 | responseData["success"] = false; |
1369 | responseData["error"] = e.Message; | 1213 | responseData["lastlogin"] = 0; |
1214 | } | ||
1215 | else | ||
1216 | { | ||
1217 | GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString()); | ||
1218 | if (userInfo != null) | ||
1219 | responseData["lastlogin"] = userInfo.Login; | ||
1220 | else | ||
1221 | responseData["lastlogin"] = 0; | ||
1370 | 1222 | ||
1371 | response.Value = responseData; | 1223 | responseData["success"] = true; |
1372 | } | 1224 | } |
1373 | 1225 | ||
1374 | m_log.Info("[RADMIN]: UserExists: request complete"); | 1226 | m_log.Info("[RADMIN]: UserExists: request complete"); |
1375 | return response; | ||
1376 | } | 1227 | } |
1377 | 1228 | ||
1378 | /// <summary> | 1229 | /// <summary> |
@@ -1417,27 +1268,23 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1417 | /// </description></item> | 1268 | /// </description></item> |
1418 | /// </list> | 1269 | /// </list> |
1419 | /// </remarks> | 1270 | /// </remarks> |
1420 | public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 1271 | private void XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1421 | { | 1272 | { |
1422 | m_log.Info("[RADMIN]: UpdateUserAccount: new request"); | 1273 | m_log.Info("[RADMIN]: UpdateUserAccount: new request"); |
1423 | m_log.Warn("[RADMIN]: This method needs update for 0.7"); | 1274 | m_log.Warn("[RADMIN]: This method needs update for 0.7"); |
1424 | 1275 | ||
1425 | XmlRpcResponse response = new XmlRpcResponse(); | 1276 | Hashtable responseData = (Hashtable)response.Value; |
1426 | Hashtable responseData = new Hashtable(); | 1277 | Hashtable requestData = (Hashtable)request.Params[0]; |
1427 | 1278 | ||
1428 | lock (m_requestLock) | 1279 | lock (m_requestLock) |
1429 | { | 1280 | { |
1430 | try | 1281 | try |
1431 | { | 1282 | { |
1432 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
1433 | |||
1434 | // check completeness | 1283 | // check completeness |
1435 | CheckStringParameters(request, new string[] { | 1284 | CheckStringParameters(requestData, responseData, new string[] { |
1436 | "password", "user_firstname", | 1285 | "user_firstname", |
1437 | "user_lastname"}); | 1286 | "user_lastname"}); |
1438 | 1287 | ||
1439 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
1440 | |||
1441 | // do the job | 1288 | // do the job |
1442 | string firstName = (string) requestData["user_firstname"]; | 1289 | string firstName = (string) requestData["user_firstname"]; |
1443 | string lastName = (string) requestData["user_lastname"]; | 1290 | string lastName = (string) requestData["user_lastname"]; |
@@ -1523,29 +1370,941 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1523 | responseData["success"] = true; | 1370 | responseData["success"] = true; |
1524 | responseData["avatar_uuid"] = account.PrincipalID.ToString(); | 1371 | responseData["avatar_uuid"] = account.PrincipalID.ToString(); |
1525 | 1372 | ||
1526 | response.Value = responseData; | ||
1527 | |||
1528 | m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", | 1373 | m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", |
1529 | firstName, lastName, | 1374 | firstName, lastName, |
1530 | account.PrincipalID); | 1375 | account.PrincipalID); |
1531 | } | 1376 | } |
1532 | catch (Exception e) | 1377 | catch (Exception e) |
1533 | { | 1378 | { |
1534 | m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0} {1}", e.Message, e.StackTrace); | ||
1535 | |||
1536 | responseData["success"] = false; | ||
1537 | responseData["avatar_uuid"] = UUID.Zero.ToString(); | 1379 | responseData["avatar_uuid"] = UUID.Zero.ToString(); |
1538 | responseData["error"] = e.Message; | ||
1539 | 1380 | ||
1540 | response.Value = responseData; | 1381 | throw e; |
1541 | } | 1382 | } |
1542 | 1383 | ||
1543 | m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); | 1384 | m_log.Info("[RADMIN]: UpdateUserAccount: request complete"); |
1544 | return response; | ||
1545 | } | 1385 | } |
1546 | } | 1386 | } |
1547 | 1387 | ||
1548 | /// <summary> | 1388 | /// <summary> |
1389 | /// Load an OAR file into a region.. | ||
1390 | /// <summary> | ||
1391 | /// <param name="request">incoming XML RPC request</param> | ||
1392 | /// <remarks> | ||
1393 | /// XmlRpcLoadOARMethod takes the following XMLRPC | ||
1394 | /// parameters | ||
1395 | /// <list type="table"> | ||
1396 | /// <listheader><term>parameter name</term><description>description</description></listheader> | ||
1397 | /// <item><term>password</term> | ||
1398 | /// <description>admin password as set in OpenSim.ini</description></item> | ||
1399 | /// <item><term>filename</term> | ||
1400 | /// <description>file name of the OAR file</description></item> | ||
1401 | /// <item><term>region_uuid</term> | ||
1402 | /// <description>UUID of the region</description></item> | ||
1403 | /// <item><term>region_name</term> | ||
1404 | /// <description>region name</description></item> | ||
1405 | /// <item><term>merge</term> | ||
1406 | /// <description>true if oar should be merged</description></item> | ||
1407 | /// <item><term>skip-assets</term> | ||
1408 | /// <description>true if assets should be skiped</description></item> | ||
1409 | /// </list> | ||
1410 | /// | ||
1411 | /// <code>region_uuid</code> takes precedence over | ||
1412 | /// <code>region_name</code> if both are present; one of both | ||
1413 | /// must be present. | ||
1414 | /// | ||
1415 | /// XmlRpcLoadOARMethod returns | ||
1416 | /// <list type="table"> | ||
1417 | /// <listheader><term>name</term><description>description</description></listheader> | ||
1418 | /// <item><term>success</term> | ||
1419 | /// <description>true or false</description></item> | ||
1420 | /// <item><term>error</term> | ||
1421 | /// <description>error message if success is false</description></item> | ||
1422 | /// </list> | ||
1423 | /// </remarks> | ||
1424 | private void XmlRpcLoadOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1425 | { | ||
1426 | m_log.Info("[RADMIN]: Received Load OAR Administrator Request"); | ||
1427 | |||
1428 | Hashtable responseData = (Hashtable)response.Value; | ||
1429 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1430 | |||
1431 | lock (m_requestLock) | ||
1432 | { | ||
1433 | try | ||
1434 | { | ||
1435 | CheckStringParameters(requestData, responseData, new string[] {"filename"}); | ||
1436 | |||
1437 | string filename = (string) requestData["filename"]; | ||
1438 | Scene scene = null; | ||
1439 | if (requestData.Contains("region_uuid")) | ||
1440 | { | ||
1441 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1442 | if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) | ||
1443 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1444 | } | ||
1445 | else if (requestData.Contains("region_name")) | ||
1446 | { | ||
1447 | string region_name = (string) requestData["region_name"]; | ||
1448 | if (!m_application.SceneManager.TryGetScene(region_name, out scene)) | ||
1449 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1450 | } | ||
1451 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1452 | |||
1453 | bool mergeOar = false; | ||
1454 | bool skipAssets = false; | ||
1455 | |||
1456 | if ((string)requestData["merge"] == "true") | ||
1457 | { | ||
1458 | mergeOar = true; | ||
1459 | } | ||
1460 | if ((string)requestData["skip-assets"] == "true") | ||
1461 | { | ||
1462 | skipAssets = true; | ||
1463 | } | ||
1464 | |||
1465 | IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); | ||
1466 | if (archiver != null) | ||
1467 | archiver.DearchiveRegion(filename, mergeOar, skipAssets, Guid.Empty); | ||
1468 | else | ||
1469 | throw new Exception("Archiver module not present for scene"); | ||
1470 | |||
1471 | responseData["loaded"] = true; | ||
1472 | } | ||
1473 | catch (Exception e) | ||
1474 | { | ||
1475 | responseData["loaded"] = false; | ||
1476 | |||
1477 | throw e; | ||
1478 | } | ||
1479 | |||
1480 | m_log.Info("[RADMIN]: Load OAR Administrator Request complete"); | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1484 | /// <summary> | ||
1485 | /// Save a region to an OAR file | ||
1486 | /// <summary> | ||
1487 | /// <param name="request">incoming XML RPC request</param> | ||
1488 | /// <remarks> | ||
1489 | /// XmlRpcSaveOARMethod takes the following XMLRPC | ||
1490 | /// parameters | ||
1491 | /// <list type="table"> | ||
1492 | /// <listheader><term>parameter name</term><description>description</description></listheader> | ||
1493 | /// <item><term>password</term> | ||
1494 | /// <description>admin password as set in OpenSim.ini</description></item> | ||
1495 | /// <item><term>filename</term> | ||
1496 | /// <description>file name for the OAR file</description></item> | ||
1497 | /// <item><term>region_uuid</term> | ||
1498 | /// <description>UUID of the region</description></item> | ||
1499 | /// <item><term>region_name</term> | ||
1500 | /// <description>region name</description></item> | ||
1501 | /// <item><term>profile</term> | ||
1502 | /// <description>profile url</description></item> | ||
1503 | /// <item><term>noassets</term> | ||
1504 | /// <description>true if no assets should be saved</description></item> | ||
1505 | /// <item><term>perm</term> | ||
1506 | /// <description>C and/or T</description></item> | ||
1507 | /// </list> | ||
1508 | /// | ||
1509 | /// <code>region_uuid</code> takes precedence over | ||
1510 | /// <code>region_name</code> if both are present; one of both | ||
1511 | /// must be present. | ||
1512 | /// | ||
1513 | /// XmlRpcLoadOARMethod returns | ||
1514 | /// <list type="table"> | ||
1515 | /// <listheader><term>name</term><description>description</description></listheader> | ||
1516 | /// <item><term>success</term> | ||
1517 | /// <description>true or false</description></item> | ||
1518 | /// <item><term>error</term> | ||
1519 | /// <description>error message if success is false</description></item> | ||
1520 | /// </list> | ||
1521 | /// </remarks> | ||
1522 | private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1523 | { | ||
1524 | m_log.Info("[RADMIN]: Received Save OAR Administrator Request"); | ||
1525 | |||
1526 | Hashtable responseData = (Hashtable)response.Value; | ||
1527 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1528 | |||
1529 | try | ||
1530 | { | ||
1531 | CheckStringParameters(requestData, responseData, new string[] {"filename"}); | ||
1532 | |||
1533 | string filename = (string)requestData["filename"]; | ||
1534 | Scene scene = null; | ||
1535 | if (requestData.Contains("region_uuid")) | ||
1536 | { | ||
1537 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1538 | if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) | ||
1539 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1540 | } | ||
1541 | else if (requestData.Contains("region_name")) | ||
1542 | { | ||
1543 | string region_name = (string) requestData["region_name"]; | ||
1544 | if (!m_application.SceneManager.TryGetScene(region_name, out scene)) | ||
1545 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1546 | } | ||
1547 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1548 | |||
1549 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
1550 | |||
1551 | //if (requestData.Contains("version")) | ||
1552 | //{ | ||
1553 | // options["version"] = (string)requestData["version"]; | ||
1554 | //} | ||
1555 | |||
1556 | if (requestData.Contains("profile")) | ||
1557 | { | ||
1558 | options["profile"] = (string)requestData["profile"]; | ||
1559 | } | ||
1560 | |||
1561 | if (requestData["noassets"].ToString() == "true") | ||
1562 | { | ||
1563 | options["noassets"] = (string)requestData["noassets"] ; | ||
1564 | } | ||
1565 | |||
1566 | if (requestData.Contains("perm")) | ||
1567 | { | ||
1568 | options["checkPermissions"] = (string)requestData["perm"]; | ||
1569 | } | ||
1570 | |||
1571 | IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); | ||
1572 | |||
1573 | if (archiver != null) | ||
1574 | { | ||
1575 | scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; | ||
1576 | archiver.ArchiveRegion(filename, options); | ||
1577 | |||
1578 | lock (m_saveOarLock) | ||
1579 | Monitor.Wait(m_saveOarLock,5000); | ||
1580 | |||
1581 | scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted; | ||
1582 | } | ||
1583 | else | ||
1584 | { | ||
1585 | throw new Exception("Archiver module not present for scene"); | ||
1586 | } | ||
1587 | |||
1588 | responseData["saved"] = true; | ||
1589 | } | ||
1590 | catch (Exception e) | ||
1591 | { | ||
1592 | responseData["saved"] = false; | ||
1593 | |||
1594 | throw e; | ||
1595 | } | ||
1596 | |||
1597 | m_log.Info("[RADMIN]: Save OAR Administrator Request complete"); | ||
1598 | } | ||
1599 | |||
1600 | private void RemoteAdminOarSaveCompleted(Guid uuid, string name) | ||
1601 | { | ||
1602 | m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name); | ||
1603 | lock (m_saveOarLock) | ||
1604 | Monitor.Pulse(m_saveOarLock); | ||
1605 | } | ||
1606 | |||
1607 | private void XmlRpcLoadXMLMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1608 | { | ||
1609 | m_log.Info("[RADMIN]: Received Load XML Administrator Request"); | ||
1610 | |||
1611 | Hashtable responseData = (Hashtable)response.Value; | ||
1612 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1613 | |||
1614 | lock (m_requestLock) | ||
1615 | { | ||
1616 | try | ||
1617 | { | ||
1618 | CheckStringParameters(requestData, responseData, new string[] {"filename"}); | ||
1619 | |||
1620 | string filename = (string) requestData["filename"]; | ||
1621 | if (requestData.Contains("region_uuid")) | ||
1622 | { | ||
1623 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1624 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1625 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1626 | |||
1627 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1628 | } | ||
1629 | else if (requestData.Contains("region_name")) | ||
1630 | { | ||
1631 | string region_name = (string) requestData["region_name"]; | ||
1632 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1633 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1634 | |||
1635 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1636 | } | ||
1637 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1638 | |||
1639 | responseData["switched"] = true; | ||
1640 | |||
1641 | string xml_version = "1"; | ||
1642 | if (requestData.Contains("xml_version")) | ||
1643 | { | ||
1644 | xml_version = (string) requestData["xml_version"]; | ||
1645 | } | ||
1646 | |||
1647 | switch (xml_version) | ||
1648 | { | ||
1649 | case "1": | ||
1650 | m_application.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0)); | ||
1651 | break; | ||
1652 | |||
1653 | case "2": | ||
1654 | m_application.SceneManager.LoadCurrentSceneFromXml2(filename); | ||
1655 | break; | ||
1656 | |||
1657 | default: | ||
1658 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | ||
1659 | } | ||
1660 | |||
1661 | responseData["loaded"] = true; | ||
1662 | } | ||
1663 | catch (Exception e) | ||
1664 | { | ||
1665 | responseData["loaded"] = false; | ||
1666 | responseData["switched"] = false; | ||
1667 | |||
1668 | throw e; | ||
1669 | } | ||
1670 | |||
1671 | m_log.Info("[RADMIN]: Load XML Administrator Request complete"); | ||
1672 | } | ||
1673 | } | ||
1674 | |||
1675 | private void XmlRpcSaveXMLMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1676 | { | ||
1677 | m_log.Info("[RADMIN]: Received Save XML Administrator Request"); | ||
1678 | |||
1679 | Hashtable responseData = (Hashtable)response.Value; | ||
1680 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1681 | |||
1682 | try | ||
1683 | { | ||
1684 | CheckStringParameters(requestData, responseData, new string[] {"filename"}); | ||
1685 | |||
1686 | string filename = (string) requestData["filename"]; | ||
1687 | if (requestData.Contains("region_uuid")) | ||
1688 | { | ||
1689 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1690 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1691 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1692 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1693 | } | ||
1694 | else if (requestData.Contains("region_name")) | ||
1695 | { | ||
1696 | string region_name = (string) requestData["region_name"]; | ||
1697 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1698 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1699 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1700 | } | ||
1701 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1702 | |||
1703 | responseData["switched"] = true; | ||
1704 | |||
1705 | string xml_version = "1"; | ||
1706 | if (requestData.Contains("xml_version")) | ||
1707 | { | ||
1708 | xml_version = (string) requestData["xml_version"]; | ||
1709 | } | ||
1710 | |||
1711 | switch (xml_version) | ||
1712 | { | ||
1713 | case "1": | ||
1714 | m_application.SceneManager.SaveCurrentSceneToXml(filename); | ||
1715 | break; | ||
1716 | |||
1717 | case "2": | ||
1718 | m_application.SceneManager.SaveCurrentSceneToXml2(filename); | ||
1719 | break; | ||
1720 | |||
1721 | default: | ||
1722 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | ||
1723 | } | ||
1724 | |||
1725 | responseData["saved"] = true; | ||
1726 | } | ||
1727 | catch (Exception e) | ||
1728 | { | ||
1729 | responseData["saved"] = false; | ||
1730 | responseData["switched"] = false; | ||
1731 | |||
1732 | throw e; | ||
1733 | } | ||
1734 | |||
1735 | m_log.Info("[RADMIN]: Save XML Administrator Request complete"); | ||
1736 | } | ||
1737 | |||
1738 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1739 | { | ||
1740 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1741 | |||
1742 | Hashtable responseData = (Hashtable)response.Value; | ||
1743 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1744 | |||
1745 | responseData["success"] = true; | ||
1746 | |||
1747 | if (requestData.Contains("region_uuid")) | ||
1748 | { | ||
1749 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1750 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1751 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1752 | |||
1753 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1754 | } | ||
1755 | else if (requestData.Contains("region_name")) | ||
1756 | { | ||
1757 | string region_name = (string) requestData["region_name"]; | ||
1758 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1759 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1760 | |||
1761 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1762 | } | ||
1763 | else | ||
1764 | { | ||
1765 | throw new Exception("neither region_name nor region_uuid given"); | ||
1766 | } | ||
1767 | |||
1768 | Scene scene = m_application.SceneManager.CurrentScene; | ||
1769 | |||
1770 | int flags; | ||
1771 | string text; | ||
1772 | int health = scene.GetHealth(out flags, out text); | ||
1773 | responseData["health"] = health; | ||
1774 | responseData["flags"] = flags; | ||
1775 | responseData["message"] = text; | ||
1776 | |||
1777 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | ||
1778 | } | ||
1779 | |||
1780 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1781 | { | ||
1782 | m_log.Info("[RADMIN]: Received Command XML Administrator Request"); | ||
1783 | |||
1784 | Hashtable responseData = (Hashtable)response.Value; | ||
1785 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1786 | |||
1787 | CheckStringParameters(requestData, responseData, new string[] {"command"}); | ||
1788 | |||
1789 | MainConsole.Instance.RunCommand(requestData["command"].ToString()); | ||
1790 | |||
1791 | m_log.Info("[RADMIN]: Command XML Administrator Request complete"); | ||
1792 | } | ||
1793 | |||
1794 | private void XmlRpcAccessListClear(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1795 | { | ||
1796 | m_log.Info("[RADMIN]: Received Access List Clear Request"); | ||
1797 | |||
1798 | Hashtable responseData = (Hashtable)response.Value; | ||
1799 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1800 | |||
1801 | responseData["success"] = true; | ||
1802 | |||
1803 | if (requestData.Contains("region_uuid")) | ||
1804 | { | ||
1805 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1806 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1807 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1808 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1809 | } | ||
1810 | else if (requestData.Contains("region_name")) | ||
1811 | { | ||
1812 | string region_name = (string) requestData["region_name"]; | ||
1813 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1814 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1815 | |||
1816 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1817 | } | ||
1818 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1819 | |||
1820 | Scene scene = m_application.SceneManager.CurrentScene; | ||
1821 | scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; | ||
1822 | |||
1823 | if (scene.RegionInfo.Persistent) | ||
1824 | scene.RegionInfo.EstateSettings.Save(); | ||
1825 | |||
1826 | m_log.Info("[RADMIN]: Access List Clear Request complete"); | ||
1827 | } | ||
1828 | |||
1829 | private void XmlRpcAccessListAdd(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1830 | { | ||
1831 | m_log.Info("[RADMIN]: Received Access List Add Request"); | ||
1832 | |||
1833 | Hashtable responseData = (Hashtable)response.Value; | ||
1834 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1835 | |||
1836 | if (requestData.Contains("region_uuid")) | ||
1837 | { | ||
1838 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1839 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1840 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1841 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1842 | } | ||
1843 | else if (requestData.Contains("region_name")) | ||
1844 | { | ||
1845 | string region_name = (string) requestData["region_name"]; | ||
1846 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1847 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1848 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1849 | } | ||
1850 | else | ||
1851 | { | ||
1852 | throw new Exception("neither region_name nor region_uuid given"); | ||
1853 | } | ||
1854 | |||
1855 | int addedUsers = 0; | ||
1856 | |||
1857 | if (requestData.Contains("users")) | ||
1858 | { | ||
1859 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
1860 | IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; | ||
1861 | Scene scene = m_application.SceneManager.CurrentScene; | ||
1862 | Hashtable users = (Hashtable) requestData["users"]; | ||
1863 | List<UUID> uuids = new List<UUID>(); | ||
1864 | foreach (string name in users.Values) | ||
1865 | { | ||
1866 | string[] parts = name.Split(); | ||
1867 | UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]); | ||
1868 | if (account != null) | ||
1869 | { | ||
1870 | uuids.Add(account.PrincipalID); | ||
1871 | m_log.DebugFormat("[RADMIN]: adding \"{0}\" to ACL for \"{1}\"", name, scene.RegionInfo.RegionName); | ||
1872 | } | ||
1873 | } | ||
1874 | List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess); | ||
1875 | foreach (UUID uuid in uuids) | ||
1876 | { | ||
1877 | if (!accessControlList.Contains(uuid)) | ||
1878 | { | ||
1879 | accessControlList.Add(uuid); | ||
1880 | addedUsers++; | ||
1881 | } | ||
1882 | } | ||
1883 | scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); | ||
1884 | if (scene.RegionInfo.Persistent) | ||
1885 | scene.RegionInfo.EstateSettings.Save(); | ||
1886 | } | ||
1887 | |||
1888 | responseData["added"] = addedUsers; | ||
1889 | |||
1890 | m_log.Info("[RADMIN]: Access List Add Request complete"); | ||
1891 | } | ||
1892 | |||
1893 | private void XmlRpcAccessListRemove(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1894 | { | ||
1895 | m_log.Info("[RADMIN]: Received Access List Remove Request"); | ||
1896 | |||
1897 | Hashtable responseData = (Hashtable)response.Value; | ||
1898 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1899 | |||
1900 | responseData["success"] = true; | ||
1901 | |||
1902 | if (requestData.Contains("region_uuid")) | ||
1903 | { | ||
1904 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1905 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1906 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1907 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1908 | } | ||
1909 | else if (requestData.Contains("region_name")) | ||
1910 | { | ||
1911 | string region_name = (string) requestData["region_name"]; | ||
1912 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1913 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1914 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1915 | } | ||
1916 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1917 | |||
1918 | int removedUsers = 0; | ||
1919 | |||
1920 | if (requestData.Contains("users")) | ||
1921 | { | ||
1922 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
1923 | IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; | ||
1924 | //UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService; | ||
1925 | Scene scene = m_application.SceneManager.CurrentScene; | ||
1926 | Hashtable users = (Hashtable) requestData["users"]; | ||
1927 | List<UUID> uuids = new List<UUID>(); | ||
1928 | foreach (string name in users.Values) | ||
1929 | { | ||
1930 | string[] parts = name.Split(); | ||
1931 | UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]); | ||
1932 | if (account != null) | ||
1933 | { | ||
1934 | uuids.Add(account.PrincipalID); | ||
1935 | } | ||
1936 | } | ||
1937 | List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess); | ||
1938 | foreach (UUID uuid in uuids) | ||
1939 | { | ||
1940 | if (accessControlList.Contains(uuid)) | ||
1941 | { | ||
1942 | accessControlList.Remove(uuid); | ||
1943 | removedUsers++; | ||
1944 | } | ||
1945 | } | ||
1946 | scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); | ||
1947 | if (scene.RegionInfo.Persistent) | ||
1948 | scene.RegionInfo.EstateSettings.Save(); | ||
1949 | } | ||
1950 | |||
1951 | responseData["removed"] = removedUsers; | ||
1952 | |||
1953 | m_log.Info("[RADMIN]: Access List Remove Request complete"); | ||
1954 | } | ||
1955 | |||
1956 | private void XmlRpcAccessListList(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
1957 | { | ||
1958 | m_log.Info("[RADMIN]: Received Access List List Request"); | ||
1959 | |||
1960 | Hashtable responseData = (Hashtable)response.Value; | ||
1961 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
1962 | |||
1963 | responseData["success"] = true; | ||
1964 | |||
1965 | if (requestData.Contains("region_uuid")) | ||
1966 | { | ||
1967 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
1968 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
1969 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
1970 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
1971 | } | ||
1972 | else if (requestData.Contains("region_name")) | ||
1973 | { | ||
1974 | string region_name = (string) requestData["region_name"]; | ||
1975 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
1976 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
1977 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
1978 | } | ||
1979 | else throw new Exception("neither region_name nor region_uuid given"); | ||
1980 | |||
1981 | Scene scene = m_application.SceneManager.CurrentScene; | ||
1982 | UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess; | ||
1983 | Hashtable users = new Hashtable(); | ||
1984 | |||
1985 | foreach (UUID user in accessControlList) | ||
1986 | { | ||
1987 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
1988 | UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, user); | ||
1989 | if (account != null) | ||
1990 | { | ||
1991 | users[user.ToString()] = account.FirstName + " " + account.LastName; | ||
1992 | } | ||
1993 | } | ||
1994 | |||
1995 | responseData["users"] = users; | ||
1996 | |||
1997 | m_log.Info("[RADMIN]: Access List List Request complete"); | ||
1998 | } | ||
1999 | |||
2000 | private void XmlRpcTeleportAgentMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
2001 | { | ||
2002 | Hashtable responseData = (Hashtable)response.Value; | ||
2003 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
2004 | |||
2005 | UUID agentId; | ||
2006 | string regionName = null; | ||
2007 | Vector3 pos, lookAt; | ||
2008 | ScenePresence sp = null; | ||
2009 | |||
2010 | if (requestData.Contains("agent_first_name") && requestData.Contains("agent_last_name")) | ||
2011 | { | ||
2012 | string firstName = requestData["agent_first_name"].ToString(); | ||
2013 | string lastName = requestData["agent_last_name"].ToString(); | ||
2014 | m_application.SceneManager.TryGetRootScenePresenceByName(firstName, lastName, out sp); | ||
2015 | |||
2016 | if (sp == null) | ||
2017 | throw new Exception( | ||
2018 | string.Format( | ||
2019 | "No agent found with agent_first_name {0} and agent_last_name {1}", firstName, lastName)); | ||
2020 | } | ||
2021 | else if (requestData.Contains("agent_id")) | ||
2022 | { | ||
2023 | string rawAgentId = (string)requestData["agent_id"]; | ||
2024 | |||
2025 | if (!UUID.TryParse(rawAgentId, out agentId)) | ||
2026 | throw new Exception(string.Format("agent_id {0} does not have the correct id format", rawAgentId)); | ||
2027 | |||
2028 | m_application.SceneManager.TryGetRootScenePresence(agentId, out sp); | ||
2029 | |||
2030 | if (sp == null) | ||
2031 | throw new Exception(string.Format("No agent with agent_id {0} found in this simulator", agentId)); | ||
2032 | } | ||
2033 | else | ||
2034 | { | ||
2035 | throw new Exception("No agent_id or agent_first_name and agent_last_name parameters specified"); | ||
2036 | } | ||
2037 | |||
2038 | if (requestData.Contains("region_name")) | ||
2039 | regionName = (string)requestData["region_name"]; | ||
2040 | |||
2041 | pos.X = ParseFloat(requestData, "pos_x", sp.AbsolutePosition.X); | ||
2042 | pos.Y = ParseFloat(requestData, "pos_y", sp.AbsolutePosition.Y); | ||
2043 | pos.Z = ParseFloat(requestData, "pos_z", sp.AbsolutePosition.Z); | ||
2044 | lookAt.X = ParseFloat(requestData, "lookat_x", sp.Lookat.X); | ||
2045 | lookAt.Y = ParseFloat(requestData, "lookat_y", sp.Lookat.Y); | ||
2046 | lookAt.Z = ParseFloat(requestData, "lookat_z", sp.Lookat.Z); | ||
2047 | |||
2048 | sp.Scene.RequestTeleportLocation( | ||
2049 | sp.ControllingClient, regionName, pos, lookAt, (uint)Constants.TeleportFlags.ViaLocation); | ||
2050 | |||
2051 | // We have no way of telling the failure of the actual teleport | ||
2052 | responseData["success"] = true; | ||
2053 | } | ||
2054 | |||
2055 | /// <summary> | ||
2056 | /// Parse a float with the given parameter name from a request data hash table. | ||
2057 | /// </summary> | ||
2058 | /// <remarks> | ||
2059 | /// Will throw an exception if parameter is not a float. | ||
2060 | /// Will not throw if parameter is not found, passes back default value instead. | ||
2061 | /// </remarks> | ||
2062 | /// <param name="requestData"></param> | ||
2063 | /// <param name="paramName"></param> | ||
2064 | /// <param name="defaultVal"></param> | ||
2065 | /// <returns></returns> | ||
2066 | private static float ParseFloat(Hashtable requestData, string paramName, float defaultVal) | ||
2067 | { | ||
2068 | if (requestData.Contains(paramName)) | ||
2069 | { | ||
2070 | string rawVal = (string)requestData[paramName]; | ||
2071 | float val; | ||
2072 | |||
2073 | if (!float.TryParse(rawVal, out val)) | ||
2074 | throw new Exception(string.Format("{0} {1} is not a valid float", paramName, rawVal)); | ||
2075 | else | ||
2076 | return val; | ||
2077 | } | ||
2078 | else | ||
2079 | { | ||
2080 | return defaultVal; | ||
2081 | } | ||
2082 | } | ||
2083 | |||
2084 | private static void CheckStringParameters(Hashtable requestData, Hashtable responseData, string[] param) | ||
2085 | { | ||
2086 | foreach (string parameter in param) | ||
2087 | { | ||
2088 | if (!requestData.Contains(parameter)) | ||
2089 | { | ||
2090 | responseData["accepted"] = false; | ||
2091 | throw new Exception(String.Format("missing string parameter {0}", parameter)); | ||
2092 | } | ||
2093 | if (String.IsNullOrEmpty((string) requestData[parameter])) | ||
2094 | { | ||
2095 | responseData["accepted"] = false; | ||
2096 | throw new Exception(String.Format("parameter {0} is empty", parameter)); | ||
2097 | } | ||
2098 | } | ||
2099 | } | ||
2100 | |||
2101 | private static void CheckIntegerParams(Hashtable requestData, Hashtable responseData, string[] param) | ||
2102 | { | ||
2103 | foreach (string parameter in param) | ||
2104 | { | ||
2105 | if (!requestData.Contains(parameter)) | ||
2106 | { | ||
2107 | responseData["accepted"] = false; | ||
2108 | throw new Exception(String.Format("missing integer parameter {0}", parameter)); | ||
2109 | } | ||
2110 | } | ||
2111 | } | ||
2112 | |||
2113 | private bool GetBoolean(Hashtable requestData, string tag, bool defaultValue) | ||
2114 | { | ||
2115 | // If an access value has been provided, apply it. | ||
2116 | if (requestData.Contains(tag)) | ||
2117 | { | ||
2118 | switch (((string)requestData[tag]).ToLower()) | ||
2119 | { | ||
2120 | case "true" : | ||
2121 | case "t" : | ||
2122 | case "1" : | ||
2123 | return true; | ||
2124 | case "false" : | ||
2125 | case "f" : | ||
2126 | case "0" : | ||
2127 | return false; | ||
2128 | default : | ||
2129 | return defaultValue; | ||
2130 | } | ||
2131 | } | ||
2132 | else | ||
2133 | return defaultValue; | ||
2134 | } | ||
2135 | |||
2136 | private int GetIntegerAttribute(XmlNode node, string attribute, int defaultValue) | ||
2137 | { | ||
2138 | try { return Convert.ToInt32(node.Attributes[attribute].Value); } catch{} | ||
2139 | return defaultValue; | ||
2140 | } | ||
2141 | |||
2142 | private uint GetUnsignedAttribute(XmlNode node, string attribute, uint defaultValue) | ||
2143 | { | ||
2144 | try { return Convert.ToUInt32(node.Attributes[attribute].Value); } catch{} | ||
2145 | return defaultValue; | ||
2146 | } | ||
2147 | |||
2148 | private string GetStringAttribute(XmlNode node, string attribute, string defaultValue) | ||
2149 | { | ||
2150 | try { return node.Attributes[attribute].Value; } catch{} | ||
2151 | return defaultValue; | ||
2152 | } | ||
2153 | |||
2154 | public void Dispose() | ||
2155 | { | ||
2156 | } | ||
2157 | |||
2158 | /// <summary> | ||
2159 | /// Create a user | ||
2160 | /// </summary> | ||
2161 | /// <param name="scopeID"></param> | ||
2162 | /// <param name="firstName"></param> | ||
2163 | /// <param name="lastName"></param> | ||
2164 | /// <param name="password"></param> | ||
2165 | /// <param name="email"></param> | ||
2166 | private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) | ||
2167 | { | ||
2168 | Scene scene = m_application.SceneManager.CurrentOrFirstScene; | ||
2169 | IUserAccountService userAccountService = scene.UserAccountService; | ||
2170 | IGridService gridService = scene.GridService; | ||
2171 | IAuthenticationService authenticationService = scene.AuthenticationService; | ||
2172 | IGridUserService gridUserService = scene.GridUserService; | ||
2173 | IInventoryService inventoryService = scene.InventoryService; | ||
2174 | |||
2175 | UserAccount account = userAccountService.GetUserAccount(scopeID, firstName, lastName); | ||
2176 | if (null == account) | ||
2177 | { | ||
2178 | account = new UserAccount(scopeID, UUID.Random(), firstName, lastName, email); | ||
2179 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
2180 | { | ||
2181 | account.ServiceURLs = new Dictionary<string, object>(); | ||
2182 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
2183 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
2184 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
2185 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
2186 | } | ||
2187 | |||
2188 | if (userAccountService.StoreUserAccount(account)) | ||
2189 | { | ||
2190 | bool success; | ||
2191 | if (authenticationService != null) | ||
2192 | { | ||
2193 | success = authenticationService.SetPassword(account.PrincipalID, password); | ||
2194 | if (!success) | ||
2195 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
2196 | firstName, lastName); | ||
2197 | } | ||
2198 | |||
2199 | GridRegion home = null; | ||
2200 | if (gridService != null) | ||
2201 | { | ||
2202 | List<GridRegion> defaultRegions = gridService.GetDefaultRegions(UUID.Zero); | ||
2203 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
2204 | home = defaultRegions[0]; | ||
2205 | |||
2206 | if (gridUserService != null && home != null) | ||
2207 | gridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
2208 | else | ||
2209 | m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.", | ||
2210 | firstName, lastName); | ||
2211 | } | ||
2212 | else | ||
2213 | m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.", | ||
2214 | firstName, lastName); | ||
2215 | |||
2216 | if (inventoryService != null) | ||
2217 | { | ||
2218 | success = inventoryService.CreateUserInventory(account.PrincipalID); | ||
2219 | if (!success) | ||
2220 | m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.", | ||
2221 | firstName, lastName); | ||
2222 | } | ||
2223 | |||
2224 | m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName); | ||
2225 | return account; | ||
2226 | } else { | ||
2227 | m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName); | ||
2228 | } | ||
2229 | } | ||
2230 | else | ||
2231 | { | ||
2232 | m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName); | ||
2233 | } | ||
2234 | return null; | ||
2235 | } | ||
2236 | |||
2237 | /// <summary> | ||
2238 | /// Change password | ||
2239 | /// </summary> | ||
2240 | /// <param name="firstName"></param> | ||
2241 | /// <param name="lastName"></param> | ||
2242 | /// <param name="password"></param> | ||
2243 | private bool ChangeUserPassword(string firstName, string lastName, string password) | ||
2244 | { | ||
2245 | Scene scene = m_application.SceneManager.CurrentOrFirstScene; | ||
2246 | IUserAccountService userAccountService = scene.UserAccountService; | ||
2247 | IAuthenticationService authenticationService = scene.AuthenticationService; | ||
2248 | |||
2249 | UserAccount account = userAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
2250 | if (null != account) | ||
2251 | { | ||
2252 | bool success = false; | ||
2253 | if (authenticationService != null) | ||
2254 | success = authenticationService.SetPassword(account.PrincipalID, password); | ||
2255 | |||
2256 | if (!success) | ||
2257 | { | ||
2258 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
2259 | firstName, lastName); | ||
2260 | return false; | ||
2261 | } | ||
2262 | return true; | ||
2263 | } | ||
2264 | else | ||
2265 | { | ||
2266 | m_log.ErrorFormat("[RADMIN]: No such user"); | ||
2267 | return false; | ||
2268 | } | ||
2269 | } | ||
2270 | |||
2271 | private bool LoadHeightmap(string file, UUID regionID) | ||
2272 | { | ||
2273 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); | ||
2274 | |||
2275 | Scene region = null; | ||
2276 | |||
2277 | if (!m_application.SceneManager.TryGetScene(regionID, out region)) | ||
2278 | { | ||
2279 | m_log.InfoFormat("[RADMIN]: unable to get a scene with that name: {0}", regionID.ToString()); | ||
2280 | return false; | ||
2281 | } | ||
2282 | |||
2283 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); | ||
2284 | if (null == terrainModule) throw new Exception("terrain module not available"); | ||
2285 | if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) | ||
2286 | { | ||
2287 | m_log.Info("[RADMIN]: Terrain path is URL"); | ||
2288 | Uri result; | ||
2289 | if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) | ||
2290 | { | ||
2291 | // the url is valid | ||
2292 | string fileType = file.Substring(file.LastIndexOf('/') + 1); | ||
2293 | terrainModule.LoadFromStream(fileType, result); | ||
2294 | } | ||
2295 | } | ||
2296 | else | ||
2297 | { | ||
2298 | terrainModule.LoadFromFile(file); | ||
2299 | } | ||
2300 | |||
2301 | m_log.Info("[RADMIN]: Load height maps request complete"); | ||
2302 | |||
2303 | return true; | ||
2304 | } | ||
2305 | |||
2306 | |||
2307 | /// <summary> | ||
1549 | /// This method is called by the user-create and user-modify methods to establish | 2308 | /// This method is called by the user-create and user-modify methods to establish |
1550 | /// or change, the user's appearance. Default avatar names can be specified via | 2309 | /// or change, the user's appearance. Default avatar names can be specified via |
1551 | /// the config file, but must correspond to avatars in the default appearance | 2310 | /// the config file, but must correspond to avatars in the default appearance |
@@ -2290,1001 +3049,5 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2290 | 3049 | ||
2291 | return true; | 3050 | return true; |
2292 | } | 3051 | } |
2293 | |||
2294 | /// <summary> | ||
2295 | /// Load an OAR file into a region.. | ||
2296 | /// <summary> | ||
2297 | /// <param name="request">incoming XML RPC request</param> | ||
2298 | /// <remarks> | ||
2299 | /// XmlRpcLoadOARMethod takes the following XMLRPC | ||
2300 | /// parameters | ||
2301 | /// <list type="table"> | ||
2302 | /// <listheader><term>parameter name</term><description>description</description></listheader> | ||
2303 | /// <item><term>password</term> | ||
2304 | /// <description>admin password as set in OpenSim.ini</description></item> | ||
2305 | /// <item><term>filename</term> | ||
2306 | /// <description>file name of the OAR file</description></item> | ||
2307 | /// <item><term>region_uuid</term> | ||
2308 | /// <description>UUID of the region</description></item> | ||
2309 | /// <item><term>region_name</term> | ||
2310 | /// <description>region name</description></item> | ||
2311 | /// <item><term>merge</term> | ||
2312 | /// <description>true if oar should be merged</description></item> | ||
2313 | /// <item><term>skip-assets</term> | ||
2314 | /// <description>true if assets should be skiped</description></item> | ||
2315 | /// </list> | ||
2316 | /// | ||
2317 | /// <code>region_uuid</code> takes precedence over | ||
2318 | /// <code>region_name</code> if both are present; one of both | ||
2319 | /// must be present. | ||
2320 | /// | ||
2321 | /// XmlRpcLoadOARMethod returns | ||
2322 | /// <list type="table"> | ||
2323 | /// <listheader><term>name</term><description>description</description></listheader> | ||
2324 | /// <item><term>success</term> | ||
2325 | /// <description>true or false</description></item> | ||
2326 | /// <item><term>error</term> | ||
2327 | /// <description>error message if success is false</description></item> | ||
2328 | /// </list> | ||
2329 | /// </remarks> | ||
2330 | public XmlRpcResponse XmlRpcLoadOARMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2331 | { | ||
2332 | m_log.Info("[RADMIN]: Received Load OAR Administrator Request"); | ||
2333 | |||
2334 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2335 | Hashtable responseData = new Hashtable(); | ||
2336 | |||
2337 | lock (m_requestLock) | ||
2338 | { | ||
2339 | try | ||
2340 | { | ||
2341 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2342 | |||
2343 | CheckStringParameters(request, new string[] { | ||
2344 | "password", "filename"}); | ||
2345 | |||
2346 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2347 | |||
2348 | string filename = (string) requestData["filename"]; | ||
2349 | Scene scene = null; | ||
2350 | if (requestData.Contains("region_uuid")) | ||
2351 | { | ||
2352 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2353 | if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) | ||
2354 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2355 | } | ||
2356 | else if (requestData.Contains("region_name")) | ||
2357 | { | ||
2358 | string region_name = (string) requestData["region_name"]; | ||
2359 | if (!m_application.SceneManager.TryGetScene(region_name, out scene)) | ||
2360 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2361 | } | ||
2362 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2363 | |||
2364 | bool mergeOar = false; | ||
2365 | bool skipAssets = false; | ||
2366 | |||
2367 | if ((string)requestData["merge"] == "true") | ||
2368 | { | ||
2369 | mergeOar = true; | ||
2370 | } | ||
2371 | if ((string)requestData["skip-assets"] == "true") | ||
2372 | { | ||
2373 | skipAssets = true; | ||
2374 | } | ||
2375 | |||
2376 | IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); | ||
2377 | if (archiver != null) | ||
2378 | archiver.DearchiveRegion(filename, mergeOar, skipAssets, Guid.Empty); | ||
2379 | else | ||
2380 | throw new Exception("Archiver module not present for scene"); | ||
2381 | |||
2382 | responseData["loaded"] = true; | ||
2383 | |||
2384 | response.Value = responseData; | ||
2385 | } | ||
2386 | catch (Exception e) | ||
2387 | { | ||
2388 | m_log.ErrorFormat("[RADMIN]: LoadOAR: {0} {1}", e.Message, e.StackTrace); | ||
2389 | |||
2390 | responseData["loaded"] = false; | ||
2391 | responseData["error"] = e.Message; | ||
2392 | |||
2393 | response.Value = responseData; | ||
2394 | } | ||
2395 | |||
2396 | m_log.Info("[RADMIN]: Load OAR Administrator Request complete"); | ||
2397 | return response; | ||
2398 | } | ||
2399 | } | ||
2400 | |||
2401 | /// <summary> | ||
2402 | /// Save a region to an OAR file | ||
2403 | /// <summary> | ||
2404 | /// <param name="request">incoming XML RPC request</param> | ||
2405 | /// <remarks> | ||
2406 | /// XmlRpcSaveOARMethod takes the following XMLRPC | ||
2407 | /// parameters | ||
2408 | /// <list type="table"> | ||
2409 | /// <listheader><term>parameter name</term><description>description</description></listheader> | ||
2410 | /// <item><term>password</term> | ||
2411 | /// <description>admin password as set in OpenSim.ini</description></item> | ||
2412 | /// <item><term>filename</term> | ||
2413 | /// <description>file name for the OAR file</description></item> | ||
2414 | /// <item><term>region_uuid</term> | ||
2415 | /// <description>UUID of the region</description></item> | ||
2416 | /// <item><term>region_name</term> | ||
2417 | /// <description>region name</description></item> | ||
2418 | /// <item><term>profile</term> | ||
2419 | /// <description>profile url</description></item> | ||
2420 | /// <item><term>noassets</term> | ||
2421 | /// <description>true if no assets should be saved</description></item> | ||
2422 | /// <item><term>perm</term> | ||
2423 | /// <description>C and/or T</description></item> | ||
2424 | /// </list> | ||
2425 | /// | ||
2426 | /// <code>region_uuid</code> takes precedence over | ||
2427 | /// <code>region_name</code> if both are present; one of both | ||
2428 | /// must be present. | ||
2429 | /// | ||
2430 | /// XmlRpcLoadOARMethod returns | ||
2431 | /// <list type="table"> | ||
2432 | /// <listheader><term>name</term><description>description</description></listheader> | ||
2433 | /// <item><term>success</term> | ||
2434 | /// <description>true or false</description></item> | ||
2435 | /// <item><term>error</term> | ||
2436 | /// <description>error message if success is false</description></item> | ||
2437 | /// </list> | ||
2438 | /// </remarks> | ||
2439 | public XmlRpcResponse XmlRpcSaveOARMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2440 | { | ||
2441 | m_log.Info("[RADMIN]: Received Save OAR Administrator Request"); | ||
2442 | |||
2443 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2444 | Hashtable responseData = new Hashtable(); | ||
2445 | |||
2446 | try | ||
2447 | { | ||
2448 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2449 | |||
2450 | CheckStringParameters(request, new string[] { | ||
2451 | "password", "filename"}); | ||
2452 | |||
2453 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2454 | |||
2455 | string filename = (string) requestData["filename"]; | ||
2456 | Scene scene = null; | ||
2457 | if (requestData.Contains("region_uuid")) | ||
2458 | { | ||
2459 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2460 | if (!m_application.SceneManager.TryGetScene(region_uuid, out scene)) | ||
2461 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2462 | } | ||
2463 | else if (requestData.Contains("region_name")) | ||
2464 | { | ||
2465 | string region_name = (string) requestData["region_name"]; | ||
2466 | if (!m_application.SceneManager.TryGetScene(region_name, out scene)) | ||
2467 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2468 | } | ||
2469 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2470 | |||
2471 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
2472 | |||
2473 | //if (requestData.Contains("version")) | ||
2474 | //{ | ||
2475 | // options["version"] = (string)requestData["version"]; | ||
2476 | //} | ||
2477 | |||
2478 | if (requestData.Contains("profile")) | ||
2479 | { | ||
2480 | options["profile"] = (string)requestData["profile"]; | ||
2481 | } | ||
2482 | |||
2483 | if (requestData["noassets"] == "true") | ||
2484 | { | ||
2485 | options["noassets"] = (string)requestData["noassets"] ; | ||
2486 | } | ||
2487 | |||
2488 | if (requestData.Contains("perm")) | ||
2489 | { | ||
2490 | options["checkPermissions"] = (string)requestData["perm"]; | ||
2491 | } | ||
2492 | |||
2493 | IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>(); | ||
2494 | |||
2495 | if (archiver != null) | ||
2496 | { | ||
2497 | scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; | ||
2498 | archiver.ArchiveRegion(filename, options); | ||
2499 | |||
2500 | lock (m_saveOarLock) | ||
2501 | Monitor.Wait(m_saveOarLock,5000); | ||
2502 | |||
2503 | scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted; | ||
2504 | } | ||
2505 | else | ||
2506 | { | ||
2507 | throw new Exception("Archiver module not present for scene"); | ||
2508 | } | ||
2509 | |||
2510 | responseData["saved"] = true; | ||
2511 | |||
2512 | response.Value = responseData; | ||
2513 | } | ||
2514 | catch (Exception e) | ||
2515 | { | ||
2516 | m_log.ErrorFormat("[RADMIN]: SaveOAR: {0} {1}", e.Message, e.StackTrace); | ||
2517 | |||
2518 | responseData["saved"] = false; | ||
2519 | responseData["error"] = e.Message; | ||
2520 | |||
2521 | response.Value = responseData; | ||
2522 | } | ||
2523 | |||
2524 | m_log.Info("[RADMIN]: Save OAR Administrator Request complete"); | ||
2525 | return response; | ||
2526 | } | ||
2527 | |||
2528 | private void RemoteAdminOarSaveCompleted(Guid uuid, string name) | ||
2529 | { | ||
2530 | m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name); | ||
2531 | lock (m_saveOarLock) Monitor.Pulse(m_saveOarLock); | ||
2532 | } | ||
2533 | |||
2534 | public XmlRpcResponse XmlRpcLoadXMLMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2535 | { | ||
2536 | m_log.Info("[RADMIN]: Received Load XML Administrator Request"); | ||
2537 | |||
2538 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2539 | Hashtable responseData = new Hashtable(); | ||
2540 | |||
2541 | lock (m_requestLock) | ||
2542 | { | ||
2543 | try | ||
2544 | { | ||
2545 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2546 | |||
2547 | CheckStringParameters(request, new string[] { | ||
2548 | "password", "filename"}); | ||
2549 | |||
2550 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2551 | |||
2552 | string filename = (string) requestData["filename"]; | ||
2553 | if (requestData.Contains("region_uuid")) | ||
2554 | { | ||
2555 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2556 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2557 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2558 | |||
2559 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2560 | } | ||
2561 | else if (requestData.Contains("region_name")) | ||
2562 | { | ||
2563 | string region_name = (string) requestData["region_name"]; | ||
2564 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2565 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2566 | |||
2567 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2568 | } | ||
2569 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2570 | |||
2571 | responseData["switched"] = true; | ||
2572 | |||
2573 | string xml_version = "1"; | ||
2574 | if (requestData.Contains("xml_version")) | ||
2575 | { | ||
2576 | xml_version = (string) requestData["xml_version"]; | ||
2577 | } | ||
2578 | |||
2579 | switch (xml_version) | ||
2580 | { | ||
2581 | case "1": | ||
2582 | m_application.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0)); | ||
2583 | break; | ||
2584 | |||
2585 | case "2": | ||
2586 | m_application.SceneManager.LoadCurrentSceneFromXml2(filename); | ||
2587 | break; | ||
2588 | |||
2589 | default: | ||
2590 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | ||
2591 | } | ||
2592 | |||
2593 | responseData["loaded"] = true; | ||
2594 | response.Value = responseData; | ||
2595 | } | ||
2596 | catch (Exception e) | ||
2597 | { | ||
2598 | m_log.ErrorFormat("[RADMIN] LoadXml: {0} {1}", e.Message, e.StackTrace); | ||
2599 | |||
2600 | responseData["loaded"] = false; | ||
2601 | responseData["switched"] = false; | ||
2602 | responseData["error"] = e.Message; | ||
2603 | |||
2604 | response.Value = responseData; | ||
2605 | } | ||
2606 | |||
2607 | m_log.Info("[RADMIN]: Load XML Administrator Request complete"); | ||
2608 | return response; | ||
2609 | } | ||
2610 | } | ||
2611 | |||
2612 | public XmlRpcResponse XmlRpcSaveXMLMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2613 | { | ||
2614 | m_log.Info("[RADMIN]: Received Save XML Administrator Request"); | ||
2615 | |||
2616 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2617 | Hashtable responseData = new Hashtable(); | ||
2618 | |||
2619 | try | ||
2620 | { | ||
2621 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2622 | |||
2623 | CheckStringParameters(request, new string[] { | ||
2624 | "password", "filename"}); | ||
2625 | |||
2626 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2627 | |||
2628 | string filename = (string) requestData["filename"]; | ||
2629 | if (requestData.Contains("region_uuid")) | ||
2630 | { | ||
2631 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2632 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2633 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2634 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2635 | } | ||
2636 | else if (requestData.Contains("region_name")) | ||
2637 | { | ||
2638 | string region_name = (string) requestData["region_name"]; | ||
2639 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2640 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2641 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2642 | } | ||
2643 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2644 | |||
2645 | responseData["switched"] = true; | ||
2646 | |||
2647 | string xml_version = "1"; | ||
2648 | if (requestData.Contains("xml_version")) | ||
2649 | { | ||
2650 | xml_version = (string) requestData["xml_version"]; | ||
2651 | } | ||
2652 | |||
2653 | switch (xml_version) | ||
2654 | { | ||
2655 | case "1": | ||
2656 | m_application.SceneManager.SaveCurrentSceneToXml(filename); | ||
2657 | break; | ||
2658 | |||
2659 | case "2": | ||
2660 | m_application.SceneManager.SaveCurrentSceneToXml2(filename); | ||
2661 | break; | ||
2662 | |||
2663 | default: | ||
2664 | throw new Exception(String.Format("unknown Xml{0} format", xml_version)); | ||
2665 | } | ||
2666 | |||
2667 | responseData["saved"] = true; | ||
2668 | |||
2669 | response.Value = responseData; | ||
2670 | } | ||
2671 | catch (Exception e) | ||
2672 | { | ||
2673 | m_log.ErrorFormat("[RADMIN]: SaveXml: {0} {1}", e.Message, e.StackTrace); | ||
2674 | |||
2675 | responseData["saved"] = false; | ||
2676 | responseData["switched"] = false; | ||
2677 | responseData["error"] = e.Message; | ||
2678 | |||
2679 | response.Value = responseData; | ||
2680 | } | ||
2681 | |||
2682 | m_log.Info("[RADMIN]: Save XML Administrator Request complete"); | ||
2683 | return response; | ||
2684 | } | ||
2685 | |||
2686 | public XmlRpcResponse XmlRpcRegionQueryMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2687 | { | ||
2688 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
2689 | |||
2690 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2691 | Hashtable responseData = new Hashtable(); | ||
2692 | |||
2693 | try | ||
2694 | { | ||
2695 | responseData["success"] = true; | ||
2696 | |||
2697 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2698 | |||
2699 | CheckStringParameters(request, new string[] { | ||
2700 | "password"}); | ||
2701 | |||
2702 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2703 | |||
2704 | if (requestData.Contains("region_uuid")) | ||
2705 | { | ||
2706 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2707 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2708 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2709 | |||
2710 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2711 | } | ||
2712 | else if (requestData.Contains("region_name")) | ||
2713 | { | ||
2714 | string region_name = (string) requestData["region_name"]; | ||
2715 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2716 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2717 | |||
2718 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2719 | } | ||
2720 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2721 | |||
2722 | Scene scene = m_application.SceneManager.CurrentScene; | ||
2723 | int flags; | ||
2724 | string text; | ||
2725 | int health = scene.GetHealth(out flags, out text); | ||
2726 | responseData["health"] = health; | ||
2727 | responseData["flags"] = flags; | ||
2728 | responseData["message"] = text; | ||
2729 | |||
2730 | response.Value = responseData; | ||
2731 | } | ||
2732 | catch (Exception e) | ||
2733 | { | ||
2734 | m_log.InfoFormat("[RADMIN]: RegionQuery: {0}", e.Message); | ||
2735 | |||
2736 | responseData["success"] = false; | ||
2737 | responseData["error"] = e.Message; | ||
2738 | |||
2739 | response.Value = responseData; | ||
2740 | } | ||
2741 | |||
2742 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | ||
2743 | |||
2744 | return response; | ||
2745 | } | ||
2746 | |||
2747 | public XmlRpcResponse XmlRpcConsoleCommandMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2748 | { | ||
2749 | m_log.Info("[RADMIN]: Received Command XML Administrator Request"); | ||
2750 | |||
2751 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2752 | Hashtable responseData = new Hashtable(); | ||
2753 | |||
2754 | try | ||
2755 | { | ||
2756 | responseData["success"] = true; | ||
2757 | |||
2758 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2759 | |||
2760 | CheckStringParameters(request, new string[] { | ||
2761 | "password", "command"}); | ||
2762 | |||
2763 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2764 | |||
2765 | MainConsole.Instance.RunCommand(requestData["command"].ToString()); | ||
2766 | |||
2767 | response.Value = responseData; | ||
2768 | } | ||
2769 | catch (Exception e) | ||
2770 | { | ||
2771 | m_log.InfoFormat("[RADMIN]: ConsoleCommand: {0}", e.Message); | ||
2772 | |||
2773 | responseData["success"] = false; | ||
2774 | responseData["error"] = e.Message; | ||
2775 | |||
2776 | response.Value = responseData; | ||
2777 | } | ||
2778 | |||
2779 | m_log.Info("[RADMIN]: Command XML Administrator Request complete"); | ||
2780 | return response; | ||
2781 | } | ||
2782 | |||
2783 | public XmlRpcResponse XmlRpcAccessListClear(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2784 | { | ||
2785 | m_log.Info("[RADMIN]: Received Access List Clear Request"); | ||
2786 | |||
2787 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2788 | Hashtable responseData = new Hashtable(); | ||
2789 | |||
2790 | try | ||
2791 | { | ||
2792 | responseData["success"] = true; | ||
2793 | |||
2794 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2795 | |||
2796 | CheckStringParameters(request, new string[] { | ||
2797 | "password"}); | ||
2798 | |||
2799 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2800 | |||
2801 | if (requestData.Contains("region_uuid")) | ||
2802 | { | ||
2803 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2804 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2805 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2806 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2807 | } | ||
2808 | else if (requestData.Contains("region_name")) | ||
2809 | { | ||
2810 | string region_name = (string) requestData["region_name"]; | ||
2811 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2812 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2813 | |||
2814 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2815 | } | ||
2816 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2817 | |||
2818 | Scene scene = m_application.SceneManager.CurrentScene; | ||
2819 | scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; | ||
2820 | |||
2821 | if (scene.RegionInfo.Persistent) | ||
2822 | scene.RegionInfo.EstateSettings.Save(); | ||
2823 | } | ||
2824 | catch (Exception e) | ||
2825 | { | ||
2826 | m_log.ErrorFormat("[RADMIN]: Access List Clear Request: {0} {1}", e.Message, e.StackTrace); | ||
2827 | |||
2828 | responseData["success"] = false; | ||
2829 | responseData["error"] = e.Message; | ||
2830 | } | ||
2831 | finally | ||
2832 | { | ||
2833 | response.Value = responseData; | ||
2834 | } | ||
2835 | |||
2836 | m_log.Info("[RADMIN]: Access List Clear Request complete"); | ||
2837 | return response; | ||
2838 | } | ||
2839 | |||
2840 | public XmlRpcResponse XmlRpcAccessListAdd(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2841 | { | ||
2842 | m_log.Info("[RADMIN]: Received Access List Add Request"); | ||
2843 | |||
2844 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2845 | Hashtable responseData = new Hashtable(); | ||
2846 | |||
2847 | try | ||
2848 | { | ||
2849 | responseData["success"] = true; | ||
2850 | |||
2851 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2852 | |||
2853 | CheckStringParameters(request, new string[] { | ||
2854 | "password"}); | ||
2855 | |||
2856 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2857 | |||
2858 | if (requestData.Contains("region_uuid")) | ||
2859 | { | ||
2860 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2861 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2862 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2863 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2864 | } | ||
2865 | else if (requestData.Contains("region_name")) | ||
2866 | { | ||
2867 | string region_name = (string) requestData["region_name"]; | ||
2868 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2869 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2870 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2871 | } | ||
2872 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2873 | |||
2874 | int addedUsers = 0; | ||
2875 | |||
2876 | if (requestData.Contains("users")) | ||
2877 | { | ||
2878 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
2879 | IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; | ||
2880 | Scene scene = m_application.SceneManager.CurrentScene; | ||
2881 | Hashtable users = (Hashtable) requestData["users"]; | ||
2882 | List<UUID> uuids = new List<UUID>(); | ||
2883 | foreach (string name in users.Values) | ||
2884 | { | ||
2885 | string[] parts = name.Split(); | ||
2886 | UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]); | ||
2887 | if (account != null) | ||
2888 | { | ||
2889 | uuids.Add(account.PrincipalID); | ||
2890 | m_log.DebugFormat("[RADMIN]: adding \"{0}\" to ACL for \"{1}\"", name, scene.RegionInfo.RegionName); | ||
2891 | } | ||
2892 | } | ||
2893 | List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess); | ||
2894 | foreach (UUID uuid in uuids) | ||
2895 | { | ||
2896 | if (!accessControlList.Contains(uuid)) | ||
2897 | { | ||
2898 | accessControlList.Add(uuid); | ||
2899 | addedUsers++; | ||
2900 | } | ||
2901 | } | ||
2902 | scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); | ||
2903 | if (scene.RegionInfo.Persistent) | ||
2904 | scene.RegionInfo.EstateSettings.Save(); | ||
2905 | } | ||
2906 | |||
2907 | responseData["added"] = addedUsers; | ||
2908 | } | ||
2909 | catch (Exception e) | ||
2910 | { | ||
2911 | m_log.ErrorFormat("[RADMIN]: Access List Add Request: {0} {1}", e.Message, e.StackTrace); | ||
2912 | |||
2913 | responseData["success"] = false; | ||
2914 | responseData["error"] = e.Message; | ||
2915 | } | ||
2916 | finally | ||
2917 | { | ||
2918 | response.Value = responseData; | ||
2919 | } | ||
2920 | |||
2921 | m_log.Info("[RADMIN]: Access List Add Request complete"); | ||
2922 | return response; | ||
2923 | } | ||
2924 | |||
2925 | public XmlRpcResponse XmlRpcAccessListRemove(XmlRpcRequest request, IPEndPoint remoteClient) | ||
2926 | { | ||
2927 | m_log.Info("[RADMIN]: Received Access List Remove Request"); | ||
2928 | |||
2929 | XmlRpcResponse response = new XmlRpcResponse(); | ||
2930 | Hashtable responseData = new Hashtable(); | ||
2931 | |||
2932 | try | ||
2933 | { | ||
2934 | responseData["success"] = true; | ||
2935 | |||
2936 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
2937 | |||
2938 | CheckStringParameters(request, new string[] { | ||
2939 | "password"}); | ||
2940 | |||
2941 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
2942 | |||
2943 | if (requestData.Contains("region_uuid")) | ||
2944 | { | ||
2945 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
2946 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
2947 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
2948 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
2949 | } | ||
2950 | else if (requestData.Contains("region_name")) | ||
2951 | { | ||
2952 | string region_name = (string) requestData["region_name"]; | ||
2953 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
2954 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
2955 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
2956 | } | ||
2957 | else throw new Exception("neither region_name nor region_uuid given"); | ||
2958 | |||
2959 | int removedUsers = 0; | ||
2960 | |||
2961 | if (requestData.Contains("users")) | ||
2962 | { | ||
2963 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
2964 | IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService; | ||
2965 | //UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService; | ||
2966 | Scene scene = m_application.SceneManager.CurrentScene; | ||
2967 | Hashtable users = (Hashtable) requestData["users"]; | ||
2968 | List<UUID> uuids = new List<UUID>(); | ||
2969 | foreach (string name in users.Values) | ||
2970 | { | ||
2971 | string[] parts = name.Split(); | ||
2972 | UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]); | ||
2973 | if (account != null) | ||
2974 | { | ||
2975 | uuids.Add(account.PrincipalID); | ||
2976 | } | ||
2977 | } | ||
2978 | List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess); | ||
2979 | foreach (UUID uuid in uuids) | ||
2980 | { | ||
2981 | if (accessControlList.Contains(uuid)) | ||
2982 | { | ||
2983 | accessControlList.Remove(uuid); | ||
2984 | removedUsers++; | ||
2985 | } | ||
2986 | } | ||
2987 | scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); | ||
2988 | if (scene.RegionInfo.Persistent) | ||
2989 | scene.RegionInfo.EstateSettings.Save(); | ||
2990 | } | ||
2991 | |||
2992 | responseData["removed"] = removedUsers; | ||
2993 | } | ||
2994 | catch (Exception e) | ||
2995 | { | ||
2996 | m_log.ErrorFormat("[RADMIN]: Access List Remove Request: {0} {1}", e.Message, e.StackTrace); | ||
2997 | |||
2998 | responseData["success"] = false; | ||
2999 | responseData["error"] = e.Message; | ||
3000 | } | ||
3001 | finally | ||
3002 | { | ||
3003 | response.Value = responseData; | ||
3004 | } | ||
3005 | |||
3006 | m_log.Info("[RADMIN]: Access List Remove Request complete"); | ||
3007 | return response; | ||
3008 | } | ||
3009 | |||
3010 | public XmlRpcResponse XmlRpcAccessListList(XmlRpcRequest request, IPEndPoint remoteClient) | ||
3011 | { | ||
3012 | m_log.Info("[RADMIN]: Received Access List List Request"); | ||
3013 | |||
3014 | XmlRpcResponse response = new XmlRpcResponse(); | ||
3015 | Hashtable responseData = new Hashtable(); | ||
3016 | |||
3017 | try | ||
3018 | { | ||
3019 | responseData["success"] = true; | ||
3020 | |||
3021 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
3022 | |||
3023 | CheckStringParameters(request, new string[] { | ||
3024 | "password"}); | ||
3025 | |||
3026 | FailIfRemoteAdminNotAllowed((string)requestData["password"], remoteClient.Address.ToString()); | ||
3027 | |||
3028 | if (requestData.Contains("region_uuid")) | ||
3029 | { | ||
3030 | UUID region_uuid = (UUID) (string) requestData["region_uuid"]; | ||
3031 | if (!m_application.SceneManager.TrySetCurrentScene(region_uuid)) | ||
3032 | throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); | ||
3033 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString()); | ||
3034 | } | ||
3035 | else if (requestData.Contains("region_name")) | ||
3036 | { | ||
3037 | string region_name = (string) requestData["region_name"]; | ||
3038 | if (!m_application.SceneManager.TrySetCurrentScene(region_name)) | ||
3039 | throw new Exception(String.Format("failed to switch to region {0}", region_name)); | ||
3040 | m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name); | ||
3041 | } | ||
3042 | else throw new Exception("neither region_name nor region_uuid given"); | ||
3043 | |||
3044 | Scene scene = m_application.SceneManager.CurrentScene; | ||
3045 | UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess; | ||
3046 | Hashtable users = new Hashtable(); | ||
3047 | |||
3048 | foreach (UUID user in accessControlList) | ||
3049 | { | ||
3050 | UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID; | ||
3051 | UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, user); | ||
3052 | if (account != null) | ||
3053 | { | ||
3054 | users[user.ToString()] = account.FirstName + " " + account.LastName; | ||
3055 | } | ||
3056 | } | ||
3057 | |||
3058 | responseData["users"] = users; | ||
3059 | } | ||
3060 | catch (Exception e) | ||
3061 | { | ||
3062 | m_log.ErrorFormat("[RADMIN]: Access List List: {0} {1}", e.Message, e.StackTrace); | ||
3063 | |||
3064 | responseData["success"] = false; | ||
3065 | responseData["error"] = e.Message; | ||
3066 | } | ||
3067 | finally | ||
3068 | { | ||
3069 | response.Value = responseData; | ||
3070 | } | ||
3071 | |||
3072 | m_log.Info("[RADMIN]: Access List List Request complete"); | ||
3073 | return response; | ||
3074 | } | ||
3075 | |||
3076 | private static void CheckStringParameters(XmlRpcRequest request, string[] param) | ||
3077 | { | ||
3078 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
3079 | foreach (string parameter in param) | ||
3080 | { | ||
3081 | if (!requestData.Contains(parameter)) | ||
3082 | throw new Exception(String.Format("missing string parameter {0}", parameter)); | ||
3083 | if (String.IsNullOrEmpty((string) requestData[parameter])) | ||
3084 | throw new Exception(String.Format("parameter {0} is empty", parameter)); | ||
3085 | } | ||
3086 | } | ||
3087 | |||
3088 | private static void CheckIntegerParams(XmlRpcRequest request, string[] param) | ||
3089 | { | ||
3090 | Hashtable requestData = (Hashtable) request.Params[0]; | ||
3091 | foreach (string parameter in param) | ||
3092 | { | ||
3093 | if (!requestData.Contains(parameter)) | ||
3094 | throw new Exception(String.Format("missing integer parameter {0}", parameter)); | ||
3095 | } | ||
3096 | } | ||
3097 | |||
3098 | private bool GetBoolean(Hashtable requestData, string tag, bool defaultValue) | ||
3099 | { | ||
3100 | // If an access value has been provided, apply it. | ||
3101 | if (requestData.Contains(tag)) | ||
3102 | { | ||
3103 | switch (((string)requestData[tag]).ToLower()) | ||
3104 | { | ||
3105 | case "true" : | ||
3106 | case "t" : | ||
3107 | case "1" : | ||
3108 | return true; | ||
3109 | case "false" : | ||
3110 | case "f" : | ||
3111 | case "0" : | ||
3112 | return false; | ||
3113 | default : | ||
3114 | return defaultValue; | ||
3115 | } | ||
3116 | } | ||
3117 | else | ||
3118 | return defaultValue; | ||
3119 | } | ||
3120 | |||
3121 | private int GetIntegerAttribute(XmlNode node, string attribute, int defaultValue) | ||
3122 | { | ||
3123 | try { return Convert.ToInt32(node.Attributes[attribute].Value); } catch{} | ||
3124 | return defaultValue; | ||
3125 | } | ||
3126 | |||
3127 | private uint GetUnsignedAttribute(XmlNode node, string attribute, uint defaultValue) | ||
3128 | { | ||
3129 | try { return Convert.ToUInt32(node.Attributes[attribute].Value); } catch{} | ||
3130 | return defaultValue; | ||
3131 | } | ||
3132 | |||
3133 | private string GetStringAttribute(XmlNode node, string attribute, string defaultValue) | ||
3134 | { | ||
3135 | try { return node.Attributes[attribute].Value; } catch{} | ||
3136 | return defaultValue; | ||
3137 | } | ||
3138 | |||
3139 | public void Dispose() | ||
3140 | { | ||
3141 | } | ||
3142 | |||
3143 | /// <summary> | ||
3144 | /// Create a user | ||
3145 | /// </summary> | ||
3146 | /// <param name="scopeID"></param> | ||
3147 | /// <param name="firstName"></param> | ||
3148 | /// <param name="lastName"></param> | ||
3149 | /// <param name="password"></param> | ||
3150 | /// <param name="email"></param> | ||
3151 | private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) | ||
3152 | { | ||
3153 | Scene scene = m_application.SceneManager.CurrentOrFirstScene; | ||
3154 | IUserAccountService userAccountService = scene.UserAccountService; | ||
3155 | IGridService gridService = scene.GridService; | ||
3156 | IAuthenticationService authenticationService = scene.AuthenticationService; | ||
3157 | IGridUserService gridUserService = scene.GridUserService; | ||
3158 | IInventoryService inventoryService = scene.InventoryService; | ||
3159 | |||
3160 | UserAccount account = userAccountService.GetUserAccount(scopeID, firstName, lastName); | ||
3161 | if (null == account) | ||
3162 | { | ||
3163 | account = new UserAccount(scopeID, UUID.Random(), firstName, lastName, email); | ||
3164 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
3165 | { | ||
3166 | account.ServiceURLs = new Dictionary<string, object>(); | ||
3167 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
3168 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
3169 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
3170 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
3171 | } | ||
3172 | |||
3173 | if (userAccountService.StoreUserAccount(account)) | ||
3174 | { | ||
3175 | bool success; | ||
3176 | if (authenticationService != null) | ||
3177 | { | ||
3178 | success = authenticationService.SetPassword(account.PrincipalID, password); | ||
3179 | if (!success) | ||
3180 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
3181 | firstName, lastName); | ||
3182 | } | ||
3183 | |||
3184 | GridRegion home = null; | ||
3185 | if (gridService != null) | ||
3186 | { | ||
3187 | List<GridRegion> defaultRegions = gridService.GetDefaultRegions(UUID.Zero); | ||
3188 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
3189 | home = defaultRegions[0]; | ||
3190 | |||
3191 | if (gridUserService != null && home != null) | ||
3192 | gridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
3193 | else | ||
3194 | m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.", | ||
3195 | firstName, lastName); | ||
3196 | } | ||
3197 | else | ||
3198 | m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.", | ||
3199 | firstName, lastName); | ||
3200 | |||
3201 | if (inventoryService != null) | ||
3202 | { | ||
3203 | success = inventoryService.CreateUserInventory(account.PrincipalID); | ||
3204 | if (!success) | ||
3205 | m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.", | ||
3206 | firstName, lastName); | ||
3207 | } | ||
3208 | |||
3209 | m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName); | ||
3210 | return account; | ||
3211 | } else { | ||
3212 | m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName); | ||
3213 | } | ||
3214 | } | ||
3215 | else | ||
3216 | { | ||
3217 | m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName); | ||
3218 | } | ||
3219 | return null; | ||
3220 | } | ||
3221 | |||
3222 | /// <summary> | ||
3223 | /// Change password | ||
3224 | /// </summary> | ||
3225 | /// <param name="firstName"></param> | ||
3226 | /// <param name="lastName"></param> | ||
3227 | /// <param name="password"></param> | ||
3228 | private bool ChangeUserPassword(string firstName, string lastName, string password) | ||
3229 | { | ||
3230 | Scene scene = m_application.SceneManager.CurrentOrFirstScene; | ||
3231 | IUserAccountService userAccountService = scene.UserAccountService; | ||
3232 | IAuthenticationService authenticationService = scene.AuthenticationService; | ||
3233 | |||
3234 | UserAccount account = userAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
3235 | if (null != account) | ||
3236 | { | ||
3237 | bool success = false; | ||
3238 | if (authenticationService != null) | ||
3239 | success = authenticationService.SetPassword(account.PrincipalID, password); | ||
3240 | |||
3241 | if (!success) | ||
3242 | { | ||
3243 | m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.", | ||
3244 | firstName, lastName); | ||
3245 | return false; | ||
3246 | } | ||
3247 | return true; | ||
3248 | } | ||
3249 | else | ||
3250 | { | ||
3251 | m_log.ErrorFormat("[RADMIN]: No such user"); | ||
3252 | return false; | ||
3253 | } | ||
3254 | } | ||
3255 | private bool LoadHeightmap(string file, UUID regionID) | ||
3256 | { | ||
3257 | m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); | ||
3258 | |||
3259 | Scene region = null; | ||
3260 | |||
3261 | if (!m_application.SceneManager.TryGetScene(regionID, out region)) | ||
3262 | { | ||
3263 | m_log.InfoFormat("[RADMIN]: unable to get a scene with that name: {0}", regionID.ToString()); | ||
3264 | return false; | ||
3265 | } | ||
3266 | |||
3267 | ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>(); | ||
3268 | if (null == terrainModule) throw new Exception("terrain module not available"); | ||
3269 | if (Uri.IsWellFormedUriString(file, UriKind.Absolute)) | ||
3270 | { | ||
3271 | m_log.Info("[RADMIN]: Terrain path is URL"); | ||
3272 | Uri result; | ||
3273 | if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result)) | ||
3274 | { | ||
3275 | // the url is valid | ||
3276 | string fileType = file.Substring(file.LastIndexOf('/') + 1); | ||
3277 | terrainModule.LoadFromStream(fileType, result); | ||
3278 | } | ||
3279 | } | ||
3280 | else | ||
3281 | { | ||
3282 | terrainModule.LoadFromFile(file); | ||
3283 | } | ||
3284 | |||
3285 | m_log.Info("[RADMIN]: Load height maps request complete"); | ||
3286 | |||
3287 | return true; | ||
3288 | } | ||
3289 | } | 3052 | } |
3290 | } | 3053 | } |
diff --git a/OpenSim/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs index a0e9ebc..1709f46 100644 --- a/OpenSim/Capabilities/CapsHandlers.cs +++ b/OpenSim/Capabilities/CapsHandlers.cs | |||
@@ -51,11 +51,10 @@ namespace OpenSim.Framework.Capabilities | |||
51 | /// supplied BaseHttpServer. | 51 | /// supplied BaseHttpServer. |
52 | /// </summary> | 52 | /// </summary> |
53 | /// <param name="httpListener">base HTTP server</param> | 53 | /// <param name="httpListener">base HTTP server</param> |
54 | /// <param name="httpListenerHostname">host name of the HTTP | 54 | /// <param name="httpListenerHostname">host name of the HTTP server</param> |
55 | /// server</param> | ||
56 | /// <param name="httpListenerPort">HTTP port</param> | 55 | /// <param name="httpListenerPort">HTTP port</param> |
57 | public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) | 56 | public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) |
58 | : this (httpListener,httpListenerHostname,httpListenerPort, false) | 57 | : this(httpListener,httpListenerHostname,httpListenerPort, false) |
59 | { | 58 | { |
60 | } | 59 | } |
61 | 60 | ||
@@ -88,44 +87,52 @@ namespace OpenSim.Framework.Capabilities | |||
88 | /// handler to be removed</param> | 87 | /// handler to be removed</param> |
89 | public void Remove(string capsName) | 88 | public void Remove(string capsName) |
90 | { | 89 | { |
91 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); | 90 | lock (m_capsHandlers) |
92 | m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); | 91 | { |
93 | m_capsHandlers.Remove(capsName); | 92 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); |
93 | m_httpListener.RemoveStreamHandler("GET", m_capsHandlers[capsName].Path); | ||
94 | m_capsHandlers.Remove(capsName); | ||
95 | } | ||
94 | } | 96 | } |
95 | 97 | ||
96 | public bool ContainsCap(string cap) | 98 | public bool ContainsCap(string cap) |
97 | { | 99 | { |
98 | return m_capsHandlers.ContainsKey(cap); | 100 | lock (m_capsHandlers) |
101 | return m_capsHandlers.ContainsKey(cap); | ||
99 | } | 102 | } |
100 | 103 | ||
101 | /// <summary> | 104 | /// <summary> |
102 | /// The indexer allows us to treat the CapsHandlers object | 105 | /// The indexer allows us to treat the CapsHandlers object |
103 | /// in an intuitive dictionary like way. | 106 | /// in an intuitive dictionary like way. |
104 | /// </summary> | 107 | /// </summary> |
105 | /// <Remarks> | 108 | /// <remarks> |
106 | /// The indexer will throw an exception when you try to | 109 | /// The indexer will throw an exception when you try to |
107 | /// retrieve a cap handler for a cap that is not contained in | 110 | /// retrieve a cap handler for a cap that is not contained in |
108 | /// CapsHandlers. | 111 | /// CapsHandlers. |
109 | /// </Remarks> | 112 | /// </remarks> |
110 | public IRequestHandler this[string idx] | 113 | public IRequestHandler this[string idx] |
111 | { | 114 | { |
112 | get | 115 | get |
113 | { | 116 | { |
114 | return m_capsHandlers[idx]; | 117 | lock (m_capsHandlers) |
118 | return m_capsHandlers[idx]; | ||
115 | } | 119 | } |
116 | 120 | ||
117 | set | 121 | set |
118 | { | 122 | { |
119 | if (m_capsHandlers.ContainsKey(idx)) | 123 | lock (m_capsHandlers) |
120 | { | 124 | { |
121 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); | 125 | if (m_capsHandlers.ContainsKey(idx)) |
122 | m_capsHandlers.Remove(idx); | 126 | { |
127 | m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); | ||
128 | m_capsHandlers.Remove(idx); | ||
129 | } | ||
130 | |||
131 | if (null == value) return; | ||
132 | |||
133 | m_capsHandlers[idx] = value; | ||
134 | m_httpListener.AddStreamHandler(value); | ||
123 | } | 135 | } |
124 | |||
125 | if (null == value) return; | ||
126 | |||
127 | m_capsHandlers[idx] = value; | ||
128 | m_httpListener.AddStreamHandler(value); | ||
129 | } | 136 | } |
130 | } | 137 | } |
131 | 138 | ||
@@ -137,9 +144,12 @@ namespace OpenSim.Framework.Capabilities | |||
137 | { | 144 | { |
138 | get | 145 | get |
139 | { | 146 | { |
140 | string[] __keys = new string[m_capsHandlers.Keys.Count]; | 147 | lock (m_capsHandlers) |
141 | m_capsHandlers.Keys.CopyTo(__keys, 0); | 148 | { |
142 | return __keys; | 149 | string[] __keys = new string[m_capsHandlers.Keys.Count]; |
150 | m_capsHandlers.Keys.CopyTo(__keys, 0); | ||
151 | return __keys; | ||
152 | } | ||
143 | } | 153 | } |
144 | } | 154 | } |
145 | 155 | ||
@@ -157,15 +167,19 @@ namespace OpenSim.Framework.Capabilities | |||
157 | protocol = "https://"; | 167 | protocol = "https://"; |
158 | 168 | ||
159 | string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); | 169 | string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); |
160 | foreach (string capsName in m_capsHandlers.Keys) | 170 | |
171 | lock (m_capsHandlers) | ||
161 | { | 172 | { |
162 | if (excludeSeed && "SEED" == capsName) | 173 | foreach (string capsName in m_capsHandlers.Keys) |
163 | continue; | 174 | { |
175 | if (excludeSeed && "SEED" == capsName) | ||
176 | continue; | ||
164 | 177 | ||
165 | caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; | 178 | caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; |
179 | } | ||
166 | } | 180 | } |
167 | 181 | ||
168 | return caps; | 182 | return caps; |
169 | } | 183 | } |
170 | } | 184 | } |
171 | } | 185 | } \ No newline at end of file |
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs index e3bf8cf..b7ca703 100644 --- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs | |||
@@ -77,8 +77,6 @@ namespace OpenSim.Capabilities.Handlers | |||
77 | { | 77 | { |
78 | try | 78 | try |
79 | { | 79 | { |
80 | // m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName); | ||
81 | |||
82 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | 80 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; |
83 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 81 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
84 | 82 | ||
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 07de27a..eabb62d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -232,9 +232,8 @@ namespace OpenSim.Framework.Console | |||
232 | 232 | ||
233 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 233 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
234 | 234 | ||
235 | m_Server.AddPollServiceHTTPHandler(uri, HandleHttpPoll, | 235 | m_Server.AddPollServiceHTTPHandler( |
236 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, | 236 | uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); |
237 | sessionID)); | ||
238 | 237 | ||
239 | XmlDocument xmldoc = new XmlDocument(); | 238 | XmlDocument xmldoc = new XmlDocument(); |
240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 239 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
@@ -266,11 +265,6 @@ namespace OpenSim.Framework.Console | |||
266 | return reply; | 265 | return reply; |
267 | } | 266 | } |
268 | 267 | ||
269 | private Hashtable HandleHttpPoll(Hashtable request) | ||
270 | { | ||
271 | return new Hashtable(); | ||
272 | } | ||
273 | |||
274 | private Hashtable HandleHttpCloseSession(Hashtable request) | 268 | private Hashtable HandleHttpCloseSession(Hashtable request) |
275 | { | 269 | { |
276 | DoExpire(); | 270 | DoExpire(); |
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 76b731f..7b0fe37 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -90,9 +90,9 @@ namespace OpenSim.Framework | |||
90 | /// <summary> | 90 | /// <summary> |
91 | /// Is the agent denoted by the given agentID a child presence in this scene? | 91 | /// Is the agent denoted by the given agentID a child presence in this scene? |
92 | /// </summary> | 92 | /// </summary> |
93 | /// | 93 | /// <remarks> |
94 | /// Used by ClientView when a 'kick everyone' or 'estate message' occurs | 94 | /// Used by ClientView when a 'kick everyone' or 'estate message' occurs |
95 | /// | 95 | /// </remarks> |
96 | /// <param name="avatarID">AvatarID to lookup</param> | 96 | /// <param name="avatarID">AvatarID to lookup</param> |
97 | /// <returns>true if the presence is a child agent, false if the presence is a root exception</returns> | 97 | /// <returns>true if the presence is a child agent, false if the presence is a root exception</returns> |
98 | /// <exception cref="System.NullReferenceException"> | 98 | /// <exception cref="System.NullReferenceException"> |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 04739fe..2c0d8f0 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -227,21 +227,17 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
227 | return new List<string>(m_HTTPHandlers.Keys); | 227 | return new List<string>(m_HTTPHandlers.Keys); |
228 | } | 228 | } |
229 | 229 | ||
230 | public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) | 230 | public bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args) |
231 | { | 231 | { |
232 | bool pollHandlerResult = false; | ||
233 | lock (m_pollHandlers) | 232 | lock (m_pollHandlers) |
234 | { | 233 | { |
235 | if (!m_pollHandlers.ContainsKey(methodName)) | 234 | if (!m_pollHandlers.ContainsKey(methodName)) |
236 | { | 235 | { |
237 | m_pollHandlers.Add(methodName,args); | 236 | m_pollHandlers.Add(methodName, args); |
238 | pollHandlerResult = true; | 237 | return true; |
239 | } | 238 | } |
240 | } | 239 | } |
241 | 240 | ||
242 | if (pollHandlerResult) | ||
243 | return AddHTTPHandler(methodName, handler); | ||
244 | |||
245 | return false; | 241 | return false; |
246 | } | 242 | } |
247 | 243 | ||
@@ -1871,8 +1867,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1871 | { | 1867 | { |
1872 | lock (m_pollHandlers) | 1868 | lock (m_pollHandlers) |
1873 | m_pollHandlers.Remove(path); | 1869 | m_pollHandlers.Remove(path); |
1874 | |||
1875 | RemoveHTTPHandler(httpMethod, path); | ||
1876 | } | 1870 | } |
1877 | 1871 | ||
1878 | public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) | 1872 | public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index fd77984..db58f6f 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | |||
@@ -77,8 +77,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
77 | /// true if the handler was successfully registered, false if a handler with the same name already existed. | 77 | /// true if the handler was successfully registered, false if a handler with the same name already existed. |
78 | /// </returns> | 78 | /// </returns> |
79 | bool AddHTTPHandler(string methodName, GenericHTTPMethod handler); | 79 | bool AddHTTPHandler(string methodName, GenericHTTPMethod handler); |
80 | 80 | ||
81 | bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args); | 81 | bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args); |
82 | 82 | ||
83 | /// <summary> | 83 | /// <summary> |
84 | /// Adds a LLSD handler, yay. | 84 | /// Adds a LLSD handler, yay. |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index e8e4f19..50baa56 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -62,6 +62,7 @@ namespace OpenSim | |||
62 | 62 | ||
63 | // These are the names of the plugin-points extended by this | 63 | // These are the names of the plugin-points extended by this |
64 | // class during system startup. | 64 | // class during system startup. |
65 | // | ||
65 | 66 | ||
66 | private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache"; | 67 | private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache"; |
67 | private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient"; | 68 | private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient"; |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 9f27abc..8ba6f61 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -361,7 +361,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
361 | // This will persist this beyond the expiry of the caps handlers | 361 | // This will persist this beyond the expiry of the caps handlers |
362 | MainServer.Instance.AddPollServiceHTTPHandler( | 362 | MainServer.Instance.AddPollServiceHTTPHandler( |
363 | capsBase + EventQueueGetUUID.ToString() + "/", | 363 | capsBase + EventQueueGetUUID.ToString() + "/", |
364 | EventQueuePoll, | ||
365 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); | 364 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); |
366 | 365 | ||
367 | Random rnd = new Random(Environment.TickCount); | 366 | Random rnd = new Random(Environment.TickCount); |
@@ -578,11 +577,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
578 | // return responsedata; | 577 | // return responsedata; |
579 | // } | 578 | // } |
580 | 579 | ||
581 | public Hashtable EventQueuePoll(Hashtable request) | ||
582 | { | ||
583 | return new Hashtable(); | ||
584 | } | ||
585 | |||
586 | // public Hashtable EventQueuePath2(Hashtable request) | 580 | // public Hashtable EventQueuePath2(Hashtable request) |
587 | // { | 581 | // { |
588 | // string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); | 582 | // string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index e61815f..45d6071 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -104,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
104 | "UploadBakedTexture", | 104 | "UploadBakedTexture", |
105 | new RestStreamHandler( | 105 | new RestStreamHandler( |
106 | "POST", | 106 | "POST", |
107 | "/CAPS/" + m_uploadBakedTexturePath, | 107 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, |
108 | new UploadBakedTextureHandler( | 108 | new UploadBakedTextureHandler( |
109 | caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture)); | 109 | caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture)); |
110 | } | 110 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 458426b..f5683f0 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -91,11 +91,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
91 | get { return null; } | 91 | get { return null; } |
92 | } | 92 | } |
93 | 93 | ||
94 | private Hashtable HandleHttpPoll(Hashtable request) | ||
95 | { | ||
96 | return new Hashtable(); | ||
97 | } | ||
98 | |||
99 | public string Name | 94 | public string Name |
100 | { | 95 | { |
101 | get { return "UrlModule"; } | 96 | get { return "UrlModule"; } |
@@ -171,9 +166,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
171 | 166 | ||
172 | string uri = "/lslhttp/" + urlcode.ToString(); | 167 | string uri = "/lslhttp/" + urlcode.ToString(); |
173 | 168 | ||
174 | m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, | 169 | m_HttpServer.AddPollServiceHTTPHandler( |
175 | new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, | 170 | uri, |
176 | urlcode)); | 171 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); |
177 | 172 | ||
178 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 173 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
179 | } | 174 | } |
@@ -213,9 +208,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
213 | 208 | ||
214 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 209 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; |
215 | 210 | ||
216 | m_HttpsServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, | 211 | m_HttpsServer.AddPollServiceHTTPHandler( |
217 | new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, | 212 | uri, |
218 | urlcode)); | 213 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); |
219 | 214 | ||
220 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 215 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
221 | } | 216 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 171443e..f9ae39c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -3241,37 +3241,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3241 | // Avatar is already disposed :/ | 3241 | // Avatar is already disposed :/ |
3242 | } | 3242 | } |
3243 | 3243 | ||
3244 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | 3244 | try |
3245 | m_eventManager.TriggerOnRemovePresence(agentID); | 3245 | { |
3246 | m_log.Debug("[Scene] Finished OnRemovePresence"); | 3246 | m_eventManager.TriggerOnRemovePresence(agentID); |
3247 | 3247 | ||
3248 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3248 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3249 | AttachmentsModule.SaveChangedAttachments(avatar); | 3249 | AttachmentsModule.SaveChangedAttachments(avatar); |
3250 | 3250 | ||
3251 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3251 | ForEachClient( |
3252 | AttachmentsModule.SaveChangedAttachments(avatar); | 3252 | delegate(IClientAPI client) |
3253 | 3253 | { | |
3254 | ForEachClient( | 3254 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3255 | delegate(IClientAPI client) | 3255 | try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } |
3256 | catch (NullReferenceException) { } | ||
3257 | }); | ||
3258 | |||
3259 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
3260 | if (agentTransactions != null) | ||
3256 | { | 3261 | { |
3257 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3262 | agentTransactions.RemoveAgentAssetTransactions(agentID); |
3258 | try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } | 3263 | } |
3259 | catch (NullReferenceException) { } | 3264 | } |
3260 | }); | 3265 | finally |
3261 | |||
3262 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
3263 | if (agentTransactions != null) | ||
3264 | { | 3266 | { |
3265 | agentTransactions.RemoveAgentAssetTransactions(agentID); | 3267 | // Always clean these structures up so that any failure above doesn't cause them to remain in the |
3268 | // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering | ||
3269 | // the same cleanup exception continually. | ||
3270 | // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE | ||
3271 | // since this would hide the underlying failure and other associated problems. | ||
3272 | m_sceneGraph.RemoveScenePresence(agentID); | ||
3273 | m_clientManager.Remove(agentID); | ||
3266 | } | 3274 | } |
3267 | 3275 | ||
3268 | // Remove the avatar from the scene | ||
3269 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3270 | m_sceneGraph.RemoveScenePresence(agentID); | ||
3271 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3272 | m_clientManager.Remove(agentID); | ||
3273 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3274 | |||
3275 | try | 3276 | try |
3276 | { | 3277 | { |
3277 | avatar.Close(); | 3278 | avatar.Close(); |
@@ -4390,7 +4391,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4390 | /// <param name="action"></param> | 4391 | /// <param name="action"></param> |
4391 | public void ForEachRootScenePresence(Action<ScenePresence> action) | 4392 | public void ForEachRootScenePresence(Action<ScenePresence> action) |
4392 | { | 4393 | { |
4393 | if(m_sceneGraph != null) | 4394 | if (m_sceneGraph != null) |
4394 | { | 4395 | { |
4395 | m_sceneGraph.ForEachAvatar(action); | 4396 | m_sceneGraph.ForEachAvatar(action); |
4396 | } | 4397 | } |
@@ -4470,9 +4471,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4470 | return m_sceneGraph.GetGroupByPrim(localID); | 4471 | return m_sceneGraph.GetGroupByPrim(localID); |
4471 | } | 4472 | } |
4472 | 4473 | ||
4473 | public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 4474 | public override bool TryGetScenePresence(UUID agentID, out ScenePresence sp) |
4474 | { | 4475 | { |
4475 | return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); | 4476 | return m_sceneGraph.TryGetScenePresence(agentID, out sp); |
4476 | } | 4477 | } |
4477 | 4478 | ||
4478 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 4479 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 0fd5164..29ab071 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -193,6 +193,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
193 | return false; | 193 | return false; |
194 | } | 194 | } |
195 | 195 | ||
196 | /// <summary> | ||
197 | /// Try to get a scene presence from the scene | ||
198 | /// </summary> | ||
199 | /// <param name="agentID"></param> | ||
200 | /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> | ||
201 | /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> | ||
196 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); | 202 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); |
197 | 203 | ||
198 | #endregion | 204 | #endregion |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 82458e2..d73a959 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -545,23 +545,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | return false; | 545 | return false; |
546 | } | 546 | } |
547 | 547 | ||
548 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) | 548 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
549 | { | 549 | { |
550 | ScenePresence avatar = null; | ||
551 | |||
552 | lock (m_localScenes) | 550 | lock (m_localScenes) |
553 | { | 551 | { |
554 | foreach (Scene mScene in m_localScenes) | 552 | foreach (Scene scene in m_localScenes) |
555 | { | 553 | { |
556 | if (mScene.TryGetScenePresence(avatarId, out avatar)) | 554 | avatar = scene.GetScenePresence(avatarId); |
557 | { | 555 | |
558 | scene = mScene; | 556 | if (avatar != null && !avatar.IsChildAgent) |
559 | return true; | 557 | return true; |
560 | } | ||
561 | } | 558 | } |
562 | } | 559 | } |
563 | 560 | ||
564 | scene = null; | 561 | avatar = null; |
565 | return false; | 562 | return false; |
566 | } | 563 | } |
567 | 564 | ||
@@ -590,6 +587,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
590 | return false; | 587 | return false; |
591 | } | 588 | } |
592 | 589 | ||
590 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | ||
591 | { | ||
592 | lock (m_localScenes) | ||
593 | { | ||
594 | foreach (Scene scene in m_localScenes) | ||
595 | { | ||
596 | sp = scene.GetScenePresence(firstName, lastName); | ||
597 | if (sp != null && !sp.IsChildAgent) | ||
598 | return true; | ||
599 | } | ||
600 | } | ||
601 | |||
602 | sp = null; | ||
603 | return false; | ||
604 | } | ||
605 | |||
593 | public void ForEachScene(Action<Scene> action) | 606 | public void ForEachScene(Action<Scene> action) |
594 | { | 607 | { |
595 | lock (m_localScenes) | 608 | lock (m_localScenes) |