aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs109
1 files changed, 104 insertions, 5 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 0a262fb..0939620 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -131,6 +131,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
131 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod); 131 availableMethods["admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod);
132 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod); 132 availableMethods["admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod);
133 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod); 133 availableMethods["admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod);
134 availableMethods["admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod);
134 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod); 135 availableMethods["admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod);
135 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod); 136 availableMethods["admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod);
136 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod); 137 availableMethods["admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
@@ -270,12 +271,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController
270 271
271 responseData["rebooting"] = true; 272 responseData["rebooting"] = true;
272 273
274 string message;
275 List<int> times = new List<int>();
276
277 if (requestData.ContainsKey("alerts"))
278 {
279 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
280 foreach (string a in alertTimes)
281 times.Add(Convert.ToInt32(a));
282 }
283 else
284 {
285 int timeout = 30;
286 if (requestData.ContainsKey("milliseconds"))
287 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
288 while (timeout > 0)
289 {
290 times.Add(timeout);
291 if (timeout > 300)
292 timeout -= 120;
293 else if (timeout > 30)
294 timeout -= 30;
295 else
296 timeout -= 15;
297 }
298 }
299
300 message = "Region is restarting in {0}. Please save what you are doing and log out.";
301
302 if (requestData.ContainsKey("message"))
303 message = requestData["message"].ToString();
304
305 bool notice = true;
306 if (requestData.ContainsKey("noticetype")
307 && ((string)requestData["noticetype"] == "dialog"))
308 {
309 notice = false;
310 }
311
273 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 312 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
274 if (restartModule != null) 313 if (restartModule != null)
275 { 314 {
276 List<int> times = new List<int> { 30, 15 }; 315 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
277
278 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
279 responseData["success"] = true; 316 responseData["success"] = true;
280 } 317 }
281 } 318 }
@@ -314,6 +351,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController
314 m_log.Info("[RADMIN]: Alert request complete"); 351 m_log.Info("[RADMIN]: Alert request complete");
315 } 352 }
316 353
354 public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
355 {
356 Hashtable responseData = (Hashtable)response.Value;
357
358 m_log.Info("[RADMIN]: Dialog request started");
359
360 try
361 {
362 Hashtable requestData = (Hashtable)request.Params[0];
363
364 string message = (string)requestData["message"];
365 string fromuuid = (string)requestData["from"];
366 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
367
368 responseData["accepted"] = true;
369 responseData["success"] = true;
370
371 m_application.SceneManager.ForEachScene(
372 delegate(Scene scene)
373 {
374 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
375 if (dialogModule != null)
376 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
377 });
378 }
379 catch (Exception e)
380 {
381 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
382 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
383
384 responseData["accepted"] = false;
385 responseData["success"] = false;
386 responseData["error"] = e.Message;
387 }
388
389 m_log.Info("[RADMIN]: Alert request complete");
390 }
391
317 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 392 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
318 { 393 {
319 m_log.Info("[RADMIN]: Load height maps request started"); 394 m_log.Info("[RADMIN]: Load height maps request started");
@@ -403,13 +478,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
403 message = "Region is going down now."; 478 message = "Region is going down now.";
404 } 479 }
405 480
406 m_application.SceneManager.ForEachScene( 481 if (requestData.ContainsKey("noticetype")
482 && ((string) requestData["noticetype"] == "dialog"))
483 {
484 m_application.SceneManager.ForEachScene(
485
407 delegate(Scene scene) 486 delegate(Scene scene)
487 {
488 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
489 if (dialogModule != null)
490 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
491 });
492 }
493 else
494 {
495 if (!requestData.ContainsKey("noticetype")
496 || ((string)requestData["noticetype"] != "none"))
497 {
498 m_application.SceneManager.ForEachScene(
499 delegate(Scene scene)
408 { 500 {
409 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 501 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
410 if (dialogModule != null) 502 if (dialogModule != null)
411 dialogModule.SendGeneralAlert(message); 503 dialogModule.SendGeneralAlert(message);
412 }); 504 });
505 }
506 }
413 507
414 // Perform shutdown 508 // Perform shutdown
415 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 509 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -1671,8 +1765,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1671 } 1765 }
1672 1766
1673 Scene scene = m_application.SceneManager.CurrentScene; 1767 Scene scene = m_application.SceneManager.CurrentScene;
1674 int health = scene.GetHealth(); 1768
1769 int flags;
1770 string text;
1771 int health = scene.GetHealth(out flags, out text);
1675 responseData["health"] = health; 1772 responseData["health"] = health;
1773 responseData["flags"] = flags;
1774 responseData["message"] = text;
1676 1775
1677 m_log.Info("[RADMIN]: Query XML Administrator Request complete"); 1776 m_log.Info("[RADMIN]: Query XML Administrator Request complete");
1678 } 1777 }