aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 a634f1c..468eeb4 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 {
@@ -434,13 +518,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
434 message = "Region is going down now."; 518 message = "Region is going down now.";
435 } 519 }
436 520
437 m_application.SceneManager.ForEachScene( 521 if (requestData.ContainsKey("noticetype")
522 && ((string) requestData["noticetype"] == "dialog"))
523 {
524 m_application.SceneManager.ForEachScene(
438 delegate(Scene scene) 525 delegate(Scene scene)
439 { 526 {
440 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 527 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
441 if (dialogModule != null) 528 if (dialogModule != null)
529 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
530 });
531 }
532 else
533 {
534 if (!requestData.ContainsKey("noticetype")
535 || ((string)requestData["noticetype"] != "none"))
536 {
537 m_application.SceneManager.ForEachScene(
538 delegate(Scene scene)
539 {
540 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
541 if (dialogModule != null)
442 dialogModule.SendGeneralAlert(message); 542 dialogModule.SendGeneralAlert(message);
443 }); 543 });
544 }
545 }
546
547
444 548
445 // Perform shutdown 549 // Perform shutdown
446 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 550 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -2616,8 +2720,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2616 else throw new Exception("neither region_name nor region_uuid given"); 2720 else throw new Exception("neither region_name nor region_uuid given");
2617 2721
2618 Scene scene = m_application.SceneManager.CurrentScene; 2722 Scene scene = m_application.SceneManager.CurrentScene;
2619 int health = scene.GetHealth(); 2723 int flags;
2724 string text;
2725 int health = scene.GetHealth(out flags, out text);
2620 responseData["health"] = health; 2726 responseData["health"] = health;
2727 responseData["flags"] = flags;
2728 responseData["message"] = text;
2621 2729
2622 response.Value = responseData; 2730 response.Value = responseData;
2623 } 2731 }
@@ -3179,4 +3287,4 @@ namespace OpenSim.ApplicationPlugins.RemoteController
3179 return true; 3287 return true;
3180 } 3288 }
3181 } 3289 }
3182} \ No newline at end of file 3290}