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