diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 103 |
1 files changed, 93 insertions, 10 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 7f1a0ed..dcc88c4 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); |
@@ -266,12 +267,48 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
266 | responseData["accepted"] = true; | 267 | responseData["accepted"] = true; |
267 | responseData["rebooting"] = true; | 268 | responseData["rebooting"] = true; |
268 | 269 | ||
270 | string message; | ||
271 | List<int> times = new List<int>(); | ||
272 | |||
273 | if (requestData.ContainsKey("alerts")) | ||
274 | { | ||
275 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); | ||
276 | foreach (string a in alertTimes) | ||
277 | times.Add(Convert.ToInt32(a)); | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | int timeout = 30; | ||
282 | if (requestData.ContainsKey("milliseconds")) | ||
283 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
284 | while (timeout > 0) | ||
285 | { | ||
286 | times.Add(timeout); | ||
287 | if (timeout > 300) | ||
288 | timeout -= 120; | ||
289 | else if (timeout > 30) | ||
290 | timeout -= 30; | ||
291 | else | ||
292 | timeout -= 15; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
297 | |||
298 | if (requestData.ContainsKey("message")) | ||
299 | message = requestData["message"].ToString(); | ||
300 | |||
301 | bool notice = true; | ||
302 | if (requestData.ContainsKey("noticetype") | ||
303 | && ((string)requestData["noticetype"] == "dialog")) | ||
304 | { | ||
305 | notice = false; | ||
306 | } | ||
307 | |||
269 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 308 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); |
270 | if (restartModule != null) | 309 | if (restartModule != null) |
271 | { | 310 | { |
272 | List<int> times = new List<int> { 30, 15 }; | 311 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); |
273 | |||
274 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | ||
275 | responseData["success"] = true; | 312 | responseData["success"] = true; |
276 | } | 313 | } |
277 | } | 314 | } |
@@ -310,6 +347,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
310 | m_log.Info("[RADMIN]: Alert request complete"); | 347 | m_log.Info("[RADMIN]: Alert request complete"); |
311 | } | 348 | } |
312 | 349 | ||
350 | public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | ||
351 | { | ||
352 | Hashtable responseData = (Hashtable)response.Value; | ||
353 | |||
354 | m_log.Info("[RADMIN]: Dialog request started"); | ||
355 | |||
356 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
357 | |||
358 | string message = (string)requestData["message"]; | ||
359 | string fromuuid = (string)requestData["from"]; | ||
360 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
361 | |||
362 | responseData["accepted"] = true; | ||
363 | responseData["success"] = true; | ||
364 | |||
365 | m_application.SceneManager.ForEachScene( | ||
366 | delegate(Scene scene) | ||
367 | { | ||
368 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
369 | if (dialogModule != null) | ||
370 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
371 | }); | ||
372 | |||
373 | m_log.Info("[RADMIN]: Dialog request complete"); | ||
374 | } | ||
375 | |||
313 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 376 | private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
314 | { | 377 | { |
315 | m_log.Info("[RADMIN]: Load height maps request started"); | 378 | m_log.Info("[RADMIN]: Load height maps request started"); |
@@ -398,13 +461,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
398 | message = "Region is going down now."; | 461 | message = "Region is going down now."; |
399 | } | 462 | } |
400 | 463 | ||
401 | m_application.SceneManager.ForEachScene( | 464 | if (requestData.ContainsKey("noticetype") |
465 | && ((string) requestData["noticetype"] == "dialog")) | ||
466 | { | ||
467 | m_application.SceneManager.ForEachScene( | ||
468 | |||
402 | delegate(Scene scene) | 469 | delegate(Scene scene) |
470 | { | ||
471 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
472 | if (dialogModule != null) | ||
473 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
474 | }); | ||
475 | } | ||
476 | else | ||
477 | { | ||
478 | if (!requestData.ContainsKey("noticetype") | ||
479 | || ((string)requestData["noticetype"] != "none")) | ||
480 | { | ||
481 | m_application.SceneManager.ForEachScene( | ||
482 | delegate(Scene scene) | ||
403 | { | 483 | { |
404 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 484 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
405 | if (dialogModule != null) | 485 | if (dialogModule != null) |
406 | dialogModule.SendGeneralAlert(message); | 486 | dialogModule.SendGeneralAlert(message); |
407 | }); | 487 | }); |
488 | } | ||
489 | } | ||
408 | 490 | ||
409 | // Perform shutdown | 491 | // Perform shutdown |
410 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 492 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -1570,21 +1652,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
1570 | 1652 | ||
1571 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1653 | private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |
1572 | { | 1654 | { |
1573 | m_log.Info("[RADMIN]: Received Query XML Administrator Request"); | ||
1574 | |||
1575 | Hashtable responseData = (Hashtable)response.Value; | 1655 | Hashtable responseData = (Hashtable)response.Value; |
1576 | Hashtable requestData = (Hashtable)request.Params[0]; | 1656 | Hashtable requestData = (Hashtable)request.Params[0]; |
1577 | 1657 | ||
1658 | responseData["success"] = true; | ||
1659 | |||
1578 | CheckRegionParams(requestData, responseData); | 1660 | CheckRegionParams(requestData, responseData); |
1579 | 1661 | ||
1580 | Scene scene = null; | 1662 | Scene scene = null; |
1581 | GetSceneFromRegionParams(requestData, responseData, out scene); | 1663 | GetSceneFromRegionParams(requestData, responseData, out scene); |
1582 | 1664 | ||
1583 | int health = scene.GetHealth(); | 1665 | int flags; |
1666 | string text; | ||
1667 | int health = scene.GetHealth(out flags, out text); | ||
1584 | responseData["health"] = health; | 1668 | responseData["health"] = health; |
1585 | 1669 | responseData["flags"] = flags; | |
1586 | responseData["success"] = true; | 1670 | responseData["message"] = text; |
1587 | m_log.Info("[RADMIN]: Query XML Administrator Request complete"); | ||
1588 | } | 1671 | } |
1589 | 1672 | ||
1590 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) | 1673 | private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) |