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 4319fa0..0c4012c 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;
@@ -230,14 +231,50 @@ namespace OpenSim.ApplicationPlugins.RemoteController
230 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) 231 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
231 throw new Exception("region not found"); 232 throw new Exception("region not found");
232 233
234 string message;
235 List<int> times = new List<int>();
236
237 if (requestData.ContainsKey("alerts"))
238 {
239 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
240 foreach (string a in alertTimes)
241 times.Add(Convert.ToInt32(a));
242 }
243 else
244 {
245 int timeout = 30;
246 if (requestData.ContainsKey("milliseconds"))
247 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
248 while (timeout > 0)
249 {
250 times.Add(timeout);
251 if (timeout > 300)
252 timeout -= 120;
253 else if (timeout > 30)
254 timeout -= 30;
255 else
256 timeout -= 15;
257 }
258 }
259
260 message = "Region is restarting in {0}. Please save what you are doing and log out.";
261
262 if (requestData.ContainsKey("message"))
263 message = requestData["message"].ToString();
264
265 bool notice = true;
266 if (requestData.ContainsKey("noticetype")
267 && ((string)requestData["noticetype"] == "dialog"))
268 {
269 notice = false;
270 }
271
233 responseData["rebooting"] = true; 272 responseData["rebooting"] = true;
234 273
235 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 274 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
236 if (restartModule != null) 275 if (restartModule != null)
237 { 276 {
238 List<int> times = new List<int> { 30, 15 }; 277 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
239
240 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
241 responseData["success"] = true; 278 responseData["success"] = true;
242 } 279 }
243 280
@@ -300,6 +337,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
300 m_log.Info("[RADMIN]: Alert request complete"); 337 m_log.Info("[RADMIN]: Alert request complete");
301 return response; 338 return response;
302 } 339 }
340 public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient)
341 {
342 XmlRpcResponse response = new XmlRpcResponse();
343 Hashtable responseData = new Hashtable();
344
345 m_log.Info("[RADMIN]: Dialog request started");
346
347 try
348 {
349 Hashtable requestData = (Hashtable)request.Params[0];
350
351 CheckStringParameters(request, new string[] { "password", "from", "message" });
352
353 if (m_requiredPassword != String.Empty &&
354 (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
355 throw new Exception("wrong password");
356
357 string message = (string)requestData["message"];
358 string fromuuid = (string)requestData["from"];
359 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
360
361 responseData["accepted"] = true;
362 responseData["success"] = true;
363 response.Value = responseData;
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 catch (Exception e)
374 {
375 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
376 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
377
378 responseData["accepted"] = false;
379 responseData["success"] = false;
380 responseData["error"] = e.Message;
381 response.Value = responseData;
382 }
383
384 m_log.Info("[RADMIN]: Alert request complete");
385 return response;
386 }
303 387
304 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) 388 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
305 { 389 {
@@ -454,13 +538,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
454 message = "Region is going down now."; 538 message = "Region is going down now.";
455 } 539 }
456 540
457 m_application.SceneManager.ForEachScene( 541 if (requestData.ContainsKey("noticetype")
542 && ((string) requestData["noticetype"] == "dialog"))
543 {
544 m_application.SceneManager.ForEachScene(
458 delegate(Scene scene) 545 delegate(Scene scene)
459 { 546 {
460 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 547 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
461 if (dialogModule != null) 548 if (dialogModule != null)
549 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
550 });
551 }
552 else
553 {
554 if (!requestData.ContainsKey("noticetype")
555 || ((string)requestData["noticetype"] != "none"))
556 {
557 m_application.SceneManager.ForEachScene(
558 delegate(Scene scene)
559 {
560 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
561 if (dialogModule != null)
462 dialogModule.SendGeneralAlert(message); 562 dialogModule.SendGeneralAlert(message);
463 }); 563 });
564 }
565 }
566
567
464 568
465 // Perform shutdown 569 // Perform shutdown
466 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 570 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -2630,8 +2734,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2630 else throw new Exception("neither region_name nor region_uuid given"); 2734 else throw new Exception("neither region_name nor region_uuid given");
2631 2735
2632 Scene scene = m_application.SceneManager.CurrentScene; 2736 Scene scene = m_application.SceneManager.CurrentScene;
2633 int health = scene.GetHealth(); 2737 int flags;
2738 string text;
2739 int health = scene.GetHealth(out flags, out text);
2634 responseData["health"] = health; 2740 responseData["health"] = health;
2741 responseData["flags"] = flags;
2742 responseData["message"] = text;
2635 2743
2636 response.Value = responseData; 2744 response.Value = responseData;
2637 } 2745 }
@@ -3159,4 +3267,4 @@ namespace OpenSim.ApplicationPlugins.RemoteController
3159 } 3267 }
3160 } 3268 }
3161 } 3269 }
3162} \ No newline at end of file 3270}