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.cs119
1 files changed, 113 insertions, 6 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index d26662f..ba461f0 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -132,6 +132,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
132 availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; 132 availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
133 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; 133 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
134 availableMethods["admin_broadcast"] = XmlRpcAlertMethod; 134 availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
135 availableMethods["admin_dialog"] = XmlRpcDialogMethod;
135 availableMethods["admin_restart"] = XmlRpcRestartMethod; 136 availableMethods["admin_restart"] = XmlRpcRestartMethod;
136 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; 137 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
137 availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; 138 availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod;
@@ -241,18 +242,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
241 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) 242 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
242 throw new Exception("region not found"); 243 throw new Exception("region not found");
243 244
245 string message;
246 List<int> times = new List<int>();
247
248 if (requestData.ContainsKey("alerts"))
249 {
250 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
251 foreach (string a in alertTimes)
252 times.Add(Convert.ToInt32(a));
253 }
254 else
255 {
256 int timeout = 30;
257 if (requestData.ContainsKey("milliseconds"))
258 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
259 while (timeout > 0)
260 {
261 times.Add(timeout);
262 if (timeout > 300)
263 timeout -= 120;
264 else if (timeout > 30)
265 timeout -= 30;
266 else
267 timeout -= 15;
268 }
269 }
270
271 message = "Region is restarting in {0}. Please save what you are doing and log out.";
272
273 if (requestData.ContainsKey("message"))
274 message = requestData["message"].ToString();
275
276 bool notice = true;
277 if (requestData.ContainsKey("noticetype")
278 && ((string)requestData["noticetype"] == "dialog"))
279 {
280 notice = false;
281 }
282
244 responseData["rebooting"] = true; 283 responseData["rebooting"] = true;
245 284
246 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 285 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
247 if (restartModule != null) 286 if (restartModule != null)
248 { 287 {
249 List<int> times = new List<int> { 30, 15 }; 288 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
250
251 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
252 responseData["success"] = true; 289 responseData["success"] = true;
253 } 290 }
254 response.Value = responseData; 291 response.Value = responseData;
255
256 } 292 }
257 catch (Exception e) 293 catch (Exception e)
258 { 294 {
@@ -311,6 +347,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
311 m_log.Info("[RADMIN]: Alert request complete"); 347 m_log.Info("[RADMIN]: Alert request complete");
312 return response; 348 return response;
313 } 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 }
314 397
315 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) 398 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
316 { 399 {
@@ -466,13 +549,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
466 message = "Region is going down now."; 549 message = "Region is going down now.";
467 } 550 }
468 551
469 m_application.SceneManager.ForEachScene( 552 if (requestData.ContainsKey("noticetype")
553 && ((string) requestData["noticetype"] == "dialog"))
554 {
555 m_application.SceneManager.ForEachScene(
470 delegate(Scene scene) 556 delegate(Scene scene)
471 { 557 {
472 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 558 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
473 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)
474 dialogModule.SendGeneralAlert(message); 573 dialogModule.SendGeneralAlert(message);
475 }); 574 });
575 }
576 }
577
578
476 579
477 // Perform shutdown 580 // Perform shutdown
478 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
@@ -2659,8 +2762,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2659 else throw new Exception("neither region_name nor region_uuid given"); 2762 else throw new Exception("neither region_name nor region_uuid given");
2660 2763
2661 Scene scene = m_application.SceneManager.CurrentScene; 2764 Scene scene = m_application.SceneManager.CurrentScene;
2662 int health = scene.GetHealth(); 2765 int flags;
2766 string text;
2767 int health = scene.GetHealth(out flags, out text);
2663 responseData["health"] = health; 2768 responseData["health"] = health;
2769 responseData["flags"] = flags;
2770 responseData["message"] = text;
2664 2771
2665 response.Value = responseData; 2772 response.Value = responseData;
2666 } 2773 }