diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 119 |
1 files changed, 113 insertions, 6 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 5a011ce..7529e01 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 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; | 134 | availableMethods["admin_save_heightmap"] = XmlRpcSaveHeightmapMethod; |
@@ -216,18 +217,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
216 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) | 217 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) |
217 | throw new Exception("region not found"); | 218 | throw new Exception("region not found"); |
218 | 219 | ||
220 | string message; | ||
221 | List<int> times = new List<int>(); | ||
222 | |||
223 | if (requestData.ContainsKey("alerts")) | ||
224 | { | ||
225 | string[] alertTimes = requestData["alerts"].ToString().Split( new char[] {','}); | ||
226 | foreach (string a in alertTimes) | ||
227 | times.Add(Convert.ToInt32(a)); | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | int timeout = 30; | ||
232 | if (requestData.ContainsKey("milliseconds")) | ||
233 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
234 | while (timeout > 0) | ||
235 | { | ||
236 | times.Add(timeout); | ||
237 | if (timeout > 300) | ||
238 | timeout -= 120; | ||
239 | else if (timeout > 30) | ||
240 | timeout -= 30; | ||
241 | else | ||
242 | timeout -= 15; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
247 | |||
248 | if (requestData.ContainsKey("message")) | ||
249 | message = requestData["message"].ToString(); | ||
250 | |||
251 | bool notice = true; | ||
252 | if (requestData.ContainsKey("noticetype") | ||
253 | && ((string)requestData["noticetype"] == "dialog")) | ||
254 | { | ||
255 | notice = false; | ||
256 | } | ||
257 | |||
219 | responseData["rebooting"] = true; | 258 | responseData["rebooting"] = true; |
220 | 259 | ||
221 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 260 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); |
222 | if (restartModule != null) | 261 | if (restartModule != null) |
223 | { | 262 | { |
224 | List<int> times = new List<int> { 30, 15 }; | 263 | restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice); |
225 | |||
226 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | ||
227 | responseData["success"] = true; | 264 | responseData["success"] = true; |
228 | } | 265 | } |
229 | response.Value = responseData; | 266 | response.Value = responseData; |
230 | |||
231 | } | 267 | } |
232 | catch (Exception e) | 268 | catch (Exception e) |
233 | { | 269 | { |
@@ -288,6 +324,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
288 | m_log.Info("[RADMIN]: Alert request complete"); | 324 | m_log.Info("[RADMIN]: Alert request complete"); |
289 | return response; | 325 | return response; |
290 | } | 326 | } |
327 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
328 | { | ||
329 | XmlRpcResponse response = new XmlRpcResponse(); | ||
330 | Hashtable responseData = new Hashtable(); | ||
331 | |||
332 | m_log.Info("[RADMIN]: Dialog request started"); | ||
333 | |||
334 | try | ||
335 | { | ||
336 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
337 | |||
338 | CheckStringParameters(request, new string[] { "password", "from", "message" }); | ||
339 | |||
340 | if (m_requiredPassword != String.Empty && | ||
341 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
342 | throw new Exception("wrong password"); | ||
343 | |||
344 | string message = (string)requestData["message"]; | ||
345 | string fromuuid = (string)requestData["from"]; | ||
346 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
347 | |||
348 | responseData["accepted"] = true; | ||
349 | responseData["success"] = true; | ||
350 | response.Value = responseData; | ||
351 | |||
352 | m_application.SceneManager.ForEachScene( | ||
353 | delegate(Scene scene) | ||
354 | { | ||
355 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
356 | if (dialogModule != null) | ||
357 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
358 | }); | ||
359 | } | ||
360 | catch (Exception e) | ||
361 | { | ||
362 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
363 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
364 | |||
365 | responseData["accepted"] = false; | ||
366 | responseData["success"] = false; | ||
367 | responseData["error"] = e.Message; | ||
368 | response.Value = responseData; | ||
369 | } | ||
370 | |||
371 | m_log.Info("[RADMIN]: Alert request complete"); | ||
372 | return response; | ||
373 | } | ||
291 | 374 | ||
292 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 375 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
293 | { | 376 | { |
@@ -449,13 +532,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
449 | message = "Region is going down now."; | 532 | message = "Region is going down now."; |
450 | } | 533 | } |
451 | 534 | ||
452 | m_application.SceneManager.ForEachScene( | 535 | if (requestData.ContainsKey("noticetype") |
536 | && ((string) requestData["noticetype"] == "dialog")) | ||
537 | { | ||
538 | m_application.SceneManager.ForEachScene( | ||
453 | delegate(Scene scene) | 539 | delegate(Scene scene) |
454 | { | 540 | { |
455 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 541 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
456 | if (dialogModule != null) | 542 | if (dialogModule != null) |
543 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
544 | }); | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | if (!requestData.ContainsKey("noticetype") | ||
549 | || ((string)requestData["noticetype"] != "none")) | ||
550 | { | ||
551 | m_application.SceneManager.ForEachScene( | ||
552 | delegate(Scene scene) | ||
553 | { | ||
554 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
555 | if (dialogModule != null) | ||
457 | dialogModule.SendGeneralAlert(message); | 556 | dialogModule.SendGeneralAlert(message); |
458 | }); | 557 | }); |
558 | } | ||
559 | } | ||
560 | |||
561 | |||
459 | 562 | ||
460 | // Perform shutdown | 563 | // Perform shutdown |
461 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 564 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |
@@ -2603,8 +2706,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2603 | else throw new Exception("neither region_name nor region_uuid given"); | 2706 | else throw new Exception("neither region_name nor region_uuid given"); |
2604 | 2707 | ||
2605 | Scene scene = m_application.SceneManager.CurrentScene; | 2708 | Scene scene = m_application.SceneManager.CurrentScene; |
2606 | int health = scene.GetHealth(); | 2709 | int flags; |
2710 | string text; | ||
2711 | int health = scene.GetHealth(out flags, out text); | ||
2607 | responseData["health"] = health; | 2712 | responseData["health"] = health; |
2713 | responseData["flags"] = flags; | ||
2714 | responseData["message"] = text; | ||
2608 | 2715 | ||
2609 | response.Value = responseData; | 2716 | response.Value = responseData; |
2610 | } | 2717 | } |