diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 97 |
1 files changed, 92 insertions, 5 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 0a262fb..7a1956f 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,32 @@ 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 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
361 | |||
362 | string message = (string)requestData["message"]; | ||
363 | string fromuuid = (string)requestData["from"]; | ||
364 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
365 | |||
366 | responseData["accepted"] = true; | ||
367 | responseData["success"] = true; | ||
368 | |||
369 | m_application.SceneManager.ForEachScene( | ||
370 | delegate(Scene scene) | ||
371 | { | ||
372 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
373 | if (dialogModule != null) | ||
374 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
375 | }); | ||
376 | |||
377 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
378 | } | ||
379 | |||
317 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 380 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
318 | { | 381 | { |
319 | m_log.Info("[RADMIN]: Load height maps request started"); | 382 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -403,13 +466,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
403 | message = "Region is going down now."; | 466 | message = "Region is going down now."; |
404 | } | 467 | } |
405 | 468 | ||
406 | m_application.SceneManager.ForEachScene( | 469 | if (requestData.ContainsKey("noticetype") |
470 | && ((string) requestData["noticetype"] == "dialog")) | ||
471 | { | ||
472 | m_application.SceneManager.ForEachScene( | ||
473 | |||
407 | delegate(Scene scene) | 474 | delegate(Scene scene) |
475 | { | ||
476 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
477 | if (dialogModule != null) | ||
478 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
479 | }); | ||
480 | } | ||
481 | else | ||
482 | { | ||
483 | if (!requestData.ContainsKey("noticetype") | ||
484 | || ((string)requestData["noticetype"] != "none")) | ||
485 | { | ||
486 | m_application.SceneManager.ForEachScene( | ||
487 | delegate(Scene scene) | ||
408 | { | 488 | { |
409 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 489 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
410 | if (dialogModule != null) | 490 | if (dialogModule != null) |
411 | dialogModule.SendGeneralAlert(message); | 491 | dialogModule.SendGeneralAlert(message); |
412 | }); | 492 | }); |
493 | } | ||
494 | } | ||
413 | 495 | ||
414 | // Perform shutdown | 496 | // Perform shutdown |
415 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 497 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1671,8 +1753,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1671 | } | 1753 | } |
1672 | 1754 | ||
1673 | Scene scene = m_application.SceneManager.CurrentScene; | 1755 | Scene scene = m_application.SceneManager.CurrentScene; |
1674 | int health = scene.GetHealth(); | 1756 | |
1757 | int flags; | ||
1758 | string text; | ||
1759 | int health = scene.GetHealth(out flags, out text); | ||
1675 | responseData["health"] = health; | 1760 | responseData["health"] = health; |
1761 | responseData["flags"] = flags; | ||
1762 | responseData["message"] = text; | ||
1676 | 1763 | ||
1677 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | 1764 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); |
1678 | } | 1765 | } |