aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController')
-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 dc4309f..10cd3d5 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -128,6 +128,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
128 availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; 128 availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod;
129 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; 129 availableMethods["admin_shutdown"] = XmlRpcShutdownMethod;
130 availableMethods["admin_broadcast"] = XmlRpcAlertMethod; 130 availableMethods["admin_broadcast"] = XmlRpcAlertMethod;
131 availableMethods["admin_dialog"] = XmlRpcDialogMethod;
131 availableMethods["admin_restart"] = XmlRpcRestartMethod; 132 availableMethods["admin_restart"] = XmlRpcRestartMethod;
132 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; 133 availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod;
133 // User management 134 // User management
@@ -215,18 +216,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
215 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) 216 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
216 throw new Exception("region not found"); 217 throw new Exception("region not found");
217 218
219 string message;
220 List<int> times = new List<int>();
221
222 if (requestData.ContainsKey("alerts"))
223 {
224 string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','});
225 foreach (string a in alertTimes)
226 times.Add(Convert.ToInt32(a));
227 }
228 else
229 {
230 int timeout = 30;
231 if (requestData.ContainsKey("milliseconds"))
232 timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000;
233 while (timeout > 0)
234 {
235 times.Add(timeout);
236 if (timeout > 300)
237 timeout -= 120;
238 else if (timeout > 30)
239 timeout -= 30;
240 else
241 timeout -= 15;
242 }
243 }
244
245 message = "Region is restarting in {0}. Please save what you are doing and log out.";
246
247 if (requestData.ContainsKey("message"))
248 message = requestData["message"].ToString();
249
250 bool notice = true;
251 if (requestData.ContainsKey("noticetype")
252 && ((string)requestData["noticetype"] == "dialog"))
253 {
254 notice = false;
255 }
256
218 responseData["rebooting"] = true; 257 responseData["rebooting"] = true;
219 258
220 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); 259 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
221 if (restartModule != null) 260 if (restartModule != null)
222 { 261 {
223 List<int> times = new List<int> { 30, 15 }; 262 restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
224
225 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
226 responseData["success"] = true; 263 responseData["success"] = true;
227 } 264 }
228 response.Value = responseData; 265 response.Value = responseData;
229
230 } 266 }
231 catch (Exception e) 267 catch (Exception e)
232 { 268 {
@@ -287,6 +323,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController
287 m_log.Info("[RADMIN]: Alert request complete"); 323 m_log.Info("[RADMIN]: Alert request complete");
288 return response; 324 return response;
289 } 325 }
326 public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient)
327 {
328 XmlRpcResponse response = new XmlRpcResponse();
329 Hashtable responseData = new Hashtable();
330
331 m_log.Info("[RADMIN]: Dialog request started");
332
333 try
334 {
335 Hashtable requestData = (Hashtable)request.Params[0];
336
337 CheckStringParameters(request, new string[] { "password", "from", "message" });
338
339 if (m_requiredPassword != String.Empty &&
340 (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
341 throw new Exception("wrong password");
342
343 string message = (string)requestData["message"];
344 string fromuuid = (string)requestData["from"];
345 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
346
347 responseData["accepted"] = true;
348 responseData["success"] = true;
349 response.Value = responseData;
350
351 m_application.SceneManager.ForEachScene(
352 delegate(Scene scene)
353 {
354 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
355 if (dialogModule != null)
356 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
357 });
358 }
359 catch (Exception e)
360 {
361 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
362 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
363
364 responseData["accepted"] = false;
365 responseData["success"] = false;
366 responseData["error"] = e.Message;
367 response.Value = responseData;
368 }
369
370 m_log.Info("[RADMIN]: Alert request complete");
371 return response;
372 }
290 373
291 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) 374 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
292 { 375 {
@@ -393,13 +476,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
393 message = "Region is going down now."; 476 message = "Region is going down now.";
394 } 477 }
395 478
396 m_application.SceneManager.ForEachScene( 479 if (requestData.ContainsKey("noticetype")
480 && ((string) requestData["noticetype"] == "dialog"))
481 {
482 m_application.SceneManager.ForEachScene(
397 delegate(Scene scene) 483 delegate(Scene scene)
398 { 484 {
399 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 485 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
400 if (dialogModule != null) 486 if (dialogModule != null)
487 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
488 });
489 }
490 else
491 {
492 if (!requestData.ContainsKey("noticetype")
493 || ((string)requestData["noticetype"] != "none"))
494 {
495 m_application.SceneManager.ForEachScene(
496 delegate(Scene scene)
497 {
498 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
499 if (dialogModule != null)
401 dialogModule.SendGeneralAlert(message); 500 dialogModule.SendGeneralAlert(message);
402 }); 501 });
502 }
503 }
504
505
403 506
404 // Perform shutdown 507 // Perform shutdown
405 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 508 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
@@ -2547,8 +2650,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
2547 else throw new Exception("neither region_name nor region_uuid given"); 2650 else throw new Exception("neither region_name nor region_uuid given");
2548 2651
2549 Scene scene = m_application.SceneManager.CurrentScene; 2652 Scene scene = m_application.SceneManager.CurrentScene;
2550 int health = scene.GetHealth(); 2653 int flags;
2654 string text;
2655 int health = scene.GetHealth(out flags, out text);
2551 responseData["health"] = health; 2656 responseData["health"] = health;
2657 responseData["flags"] = flags;
2658 responseData["message"] = text;
2552 2659
2553 response.Value = responseData; 2660 response.Value = responseData;
2554 } 2661 }