aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs123
1 files changed, 112 insertions, 11 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 24570d6..49a8e64 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);
@@ -262,16 +263,70 @@ namespace OpenSim.ApplicationPlugins.RemoteController
262 Scene rebootedScene = null; 263 Scene rebootedScene = null;
263 GetSceneFromRegionParams(requestData, responseData, out rebootedScene); 264 GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
264 265
266 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
267
265 responseData["success"] = false; 268 responseData["success"] = false;
266 responseData["accepted"] = true; 269 responseData["accepted"] = true;
267 responseData["rebooting"] = true; 270 responseData["rebooting"] = true;
268 271
269 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 272 string message;
270 if (restartModule != null) 273 List<int> times = new List<int>();
274
275 if (requestData.ContainsKey("alerts"))
276 {
277 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
278 if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1)
279 {
280 if (restartModule != null)
281 {
282 message = "Restart has been cancelled";
283
284 if (requestData.ContainsKey("message"))
285 message = requestData["message"].ToString();
286
287 restartModule.AbortRestart(message);
288
289 responseData["success"] = true;
290 responseData["rebooting"] = false;
291
292 return;
293 }
294 }
295 foreach (string a in alertTimes)
296 times.Add(Convert.ToInt32(a));
297 }
298 else
271 { 299 {
272 List<int> times = new List<int> { 30, 15 }; 300 int timeout = 30;
301 if (requestData.ContainsKey("milliseconds"))
302 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
303 while (timeout > 0)
304 {
305 times.Add(timeout);
306 if (timeout > 300)
307 timeout -= 120;
308 else if (timeout > 30)
309 timeout -= 30;
310 else
311 timeout -= 15;
312 }
313 }
314
315 message = "Region is restarting in {0}. Please save what you are doing and log out.";
273 316
274 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 317 if (requestData.ContainsKey("message"))
318 message = requestData["message"].ToString();
319
320 bool notice = true;
321 if (requestData.ContainsKey("noticetype")
322 && ((string)requestData["noticetype"] == "dialog"))
323 {
324 notice = false;
325 }
326
327 if (restartModule != null)
328 {
329 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
275 responseData["success"] = true; 330 responseData["success"] = true;
276 } 331 }
277 } 332 }
@@ -310,6 +365,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
310 m_log.Info("[RADMIN]: Alert request complete"); 365 m_log.Info("[RADMIN]: Alert request complete");
311 } 366 }
312 367
368 public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
369 {
370 Hashtable responseData = (Hashtable)response.Value;
371
372 m_log.Info("[RADMIN]: Dialog request started");
373
374 Hashtable requestData = (Hashtable)request.Params[0];
375
376 string message = (string)requestData["message"];
377 string fromuuid = (string)requestData["from"];
378 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
379
380 responseData["accepted"] = true;
381 responseData["success"] = true;
382
383 m_application.SceneManager.ForEachScene(
384 delegate(Scene scene)
385 {
386 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
387 if (dialogModule != null)
388 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
389 });
390
391 m_log.Info("[RADMIN]: Dialog request complete");
392 }
393
313 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 394 private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
314 { 395 {
315 m_log.Info("[RADMIN]: Load height maps request started"); 396 m_log.Info("[RADMIN]: Load height maps request started");
@@ -398,13 +479,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController
398 message = "Region is going down now."; 479 message = "Region is going down now.";
399 } 480 }
400 481
401 m_application.SceneManager.ForEachScene( 482 if (requestData.ContainsKey("noticetype")
483 && ((string) requestData["noticetype"] == "dialog"))
484 {
485 m_application.SceneManager.ForEachScene(
486
402 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)
403 { 501 {
404 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 502 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
405 if (dialogModule != null) 503 if (dialogModule != null)
406 dialogModule.SendGeneralAlert(message); 504 dialogModule.SendGeneralAlert(message);
407 }); 505 });
506 }
507 }
408 508
409 // Perform shutdown 509 // Perform shutdown
410 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
@@ -1570,21 +1670,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1570 1670
1571 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1671 private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
1572 { 1672 {
1573 m_log.Info("[RADMIN]: Received Query XML Administrator Request");
1574
1575 Hashtable responseData = (Hashtable)response.Value; 1673 Hashtable responseData = (Hashtable)response.Value;
1576 Hashtable requestData = (Hashtable)request.Params[0]; 1674 Hashtable requestData = (Hashtable)request.Params[0];
1577 1675
1676 responseData["success"] = true;
1677
1578 CheckRegionParams(requestData, responseData); 1678 CheckRegionParams(requestData, responseData);
1579 1679
1580 Scene scene = null; 1680 Scene scene = null;
1581 GetSceneFromRegionParams(requestData, responseData, out scene); 1681 GetSceneFromRegionParams(requestData, responseData, out scene);
1582 1682
1583 int health = scene.GetHealth(); 1683 int flags;
1684 string text;
1685 int health = scene.GetHealth(out flags, out text);
1584 responseData["health"] = health; 1686 responseData["health"] = health;
1585 1687 responseData["flags"] = flags;
1586 responseData["success"] = true; 1688 responseData["message"] = text;
1587 m_log.Info("[RADMIN]: Query XML Administrator Request complete");
1588 } 1689 }
1589 1690
1590 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient) 1691 private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)