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.cs120
1 files changed, 114 insertions, 6 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index e897f7c..bcf98a1 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"] = XmlRpcRegionQueryMethod; 131 availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
132 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; 132 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
133 availableMethods["admin_broadcast"] = XmlRpcAlertMethod; 133 availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
134 availableMethods["admin_dialog"] = XmlRpcDialogMethod;
134 availableMethods["admin_restart"] = XmlRpcRestartMethod; 135 availableMethods["admin_restart"] = XmlRpcRestartMethod;
135 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; 136 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
136 availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; 137 availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod;
@@ -240,14 +241,50 @@ namespace OpenSim.ApplicationPlugins.RemoteController
240 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) 241 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
241 throw new Exception("region not found"); 242 throw new Exception("region not found");
242 243
244 string message;
245 List<int> times = new List<int>();
246
247 if (requestData.ContainsKey("alerts"))
248 {
249 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
250 foreach (string a in alertTimes)
251 times.Add(Convert.ToInt32(a));
252 }
253 else
254 {
255 int timeout = 30;
256 if (requestData.ContainsKey("milliseconds"))
257 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
258 while (timeout > 0)
259 {
260 times.Add(timeout);
261 if (timeout > 300)
262 timeout -= 120;
263 else if (timeout > 30)
264 timeout -= 30;
265 else
266 timeout -= 15;
267 }
268 }
269
270 message = "Region is restarting in {0}. Please save what you are doing and log out.";
271
272 if (requestData.ContainsKey("message"))
273 message = requestData["message"].ToString();
274
275 bool notice = true;
276 if (requestData.ContainsKey("noticetype")
277 && ((string)requestData["noticetype"] == "dialog"))
278 {
279 notice = false;
280 }
281
243 responseData["rebooting"] = true; 282 responseData["rebooting"] = true;
244 283
245 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 284 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
246 if (restartModule != null) 285 if (restartModule != null)
247 { 286 {
248 List<int> times = new List<int> { 30, 15 }; 287 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
249
250 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
251 responseData["success"] = true; 288 responseData["success"] = true;
252 } 289 }
253 290
@@ -310,6 +347,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
310 m_log.Info("[RADMIN]: Alert request complete"); 347 m_log.Info("[RADMIN]: Alert request complete");
311 return response; 348 return response;
312 } 349 }
350 public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient)
351 {
352 XmlRpcResponse response = new XmlRpcResponse();
353 Hashtable responseData = new Hashtable();
354
355 m_log.Info("[RADMIN]: Dialog request started");
356
357 try
358 {
359 Hashtable requestData = (Hashtable)request.Params[0];
360
361 CheckStringParameters(request, new string[] { "password", "from", "message" });
362
363 if (m_requiredPassword != String.Empty &&
364 (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
365 throw new Exception("wrong password");
366
367 string message = (string)requestData["message"];
368 string fromuuid = (string)requestData["from"];
369 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
370
371 responseData["accepted"] = true;
372 responseData["success"] = true;
373 response.Value = responseData;
374
375 m_application.SceneManager.ForEachScene(
376 delegate(Scene scene)
377 {
378 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
379 if (dialogModule != null)
380 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
381 });
382 }
383 catch (Exception e)
384 {
385 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
386 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
387
388 responseData["accepted"] = false;
389 responseData["success"] = false;
390 responseData["error"] = e.Message;
391 response.Value = responseData;
392 }
393
394 m_log.Info("[RADMIN]: Alert request complete");
395 return response;
396 }
313 397
314 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) 398 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
315 { 399 {
@@ -465,13 +549,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
465 message = "Region is going down now."; 549 message = "Region is going down now.";
466 } 550 }
467 551
468 m_application.SceneManager.ForEachScene( 552 if (requestData.ContainsKey("noticetype")
553 && ((string) requestData["noticetype"] == "dialog"))
554 {
555 m_application.SceneManager.ForEachScene(
469 delegate(Scene scene) 556 delegate(Scene scene)
470 { 557 {
471 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 558 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
472 if (dialogModule != null) 559 if (dialogModule != null)
560 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
561 });
562 }
563 else
564 {
565 if (!requestData.ContainsKey("noticetype")
566 || ((string)requestData["noticetype"] != "none"))
567 {
568 m_application.SceneManager.ForEachScene(
569 delegate(Scene scene)
570 {
571 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
572 if (dialogModule != null)
473 dialogModule.SendGeneralAlert(message); 573 dialogModule.SendGeneralAlert(message);
474 }); 574 });
575 }
576 }
577
578
475 579
476 // Perform shutdown 580 // Perform shutdown
477 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 581 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -2658,8 +2762,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2658 else throw new Exception("neither region_name nor region_uuid given"); 2762 else throw new Exception("neither region_name nor region_uuid given");
2659 2763
2660 Scene scene = m_application.SceneManager.CurrentScene; 2764 Scene scene = m_application.SceneManager.CurrentScene;
2661 int health = scene.GetHealth(); 2765 int flags;
2766 string text;
2767 int health = scene.GetHealth(out flags, out text);
2662 responseData["health"] = health; 2768 responseData["health"] = health;
2769 responseData["flags"] = flags;
2770 responseData["message"] = text;
2663 2771
2664 response.Value = responseData; 2772 response.Value = responseData;
2665 } 2773 }
@@ -3197,4 +3305,4 @@ namespace OpenSim.ApplicationPlugins.RemoteController
3197 } 3305 }
3198 } 3306 }
3199 } 3307 }
3200} \ No newline at end of file 3308}