diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 92 |
1 files changed, 89 insertions, 3 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 1b4d1ea..7be152b 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,6 +216,25 @@ 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 | int timeout = 30; | ||
220 | string message; | ||
221 | |||
222 | if (requestData.ContainsKey("restart") | ||
223 | && ((string)requestData["restart"] == "delayed") | ||
224 | && requestData.ContainsKey("milliseconds")) | ||
225 | { | ||
226 | timeout = Int32.Parse(requestData["milliseconds"].ToString()) / 1000; | ||
227 | } | ||
228 | |||
229 | message = "Region is restarting in {0}. Please save what you are doing and log out."; | ||
230 | |||
231 | bool notice = true; | ||
232 | if (requestData.ContainsKey("noticetype") | ||
233 | && ((string)requestData["noticetype"] == "dialog")) | ||
234 | { | ||
235 | notice = false; | ||
236 | } | ||
237 | |||
218 | responseData["rebooting"] = true; | 238 | responseData["rebooting"] = true; |
219 | 239 | ||
220 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); | 240 | IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>(); |
@@ -222,11 +242,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
222 | { | 242 | { |
223 | List<int> times = new List<int> { 30, 15 }; | 243 | List<int> times = new List<int> { 30, 15 }; |
224 | 244 | ||
225 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 245 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), notice); |
226 | responseData["success"] = true; | 246 | responseData["success"] = true; |
227 | } | 247 | } |
228 | response.Value = responseData; | 248 | response.Value = responseData; |
229 | |||
230 | } | 249 | } |
231 | catch (Exception e) | 250 | catch (Exception e) |
232 | { | 251 | { |
@@ -289,6 +308,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
289 | m_log.Info("[RADMIN]: Alert request complete"); | 308 | m_log.Info("[RADMIN]: Alert request complete"); |
290 | return response; | 309 | return response; |
291 | } | 310 | } |
311 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
312 | { | ||
313 | XmlRpcResponse response = new XmlRpcResponse(); | ||
314 | Hashtable responseData = new Hashtable(); | ||
315 | |||
316 | m_log.Info("[RADMIN]: Dialog request started"); | ||
317 | |||
318 | try | ||
319 | { | ||
320 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
321 | |||
322 | CheckStringParameters(request, new string[] { "password", "from", "message" }); | ||
323 | |||
324 | if (m_requiredPassword != String.Empty && | ||
325 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
326 | throw new Exception("wrong password"); | ||
327 | |||
328 | string message = (string)requestData["message"]; | ||
329 | string fromuuid = (string)requestData["from"]; | ||
330 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
331 | |||
332 | responseData["accepted"] = true; | ||
333 | responseData["success"] = true; | ||
334 | response.Value = responseData; | ||
335 | |||
336 | m_application.SceneManager.ForEachScene( | ||
337 | delegate(Scene scene) | ||
338 | { | ||
339 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
340 | if (dialogModule != null) | ||
341 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
342 | }); | ||
343 | } | ||
344 | catch (Exception e) | ||
345 | { | ||
346 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
347 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
348 | |||
349 | responseData["accepted"] = false; | ||
350 | responseData["success"] = false; | ||
351 | responseData["error"] = e.Message; | ||
352 | response.Value = responseData; | ||
353 | } | ||
354 | |||
355 | m_log.Info("[RADMIN]: Alert request complete"); | ||
356 | return response; | ||
357 | } | ||
292 | 358 | ||
293 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 359 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
294 | { | 360 | { |
@@ -396,13 +462,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
396 | message = "Region is going down now."; | 462 | message = "Region is going down now."; |
397 | } | 463 | } |
398 | 464 | ||
399 | m_application.SceneManager.ForEachScene( | 465 | if (requestData.ContainsKey("noticetype") |
466 | && ((string) requestData["noticetype"] == "dialog")) | ||
467 | { | ||
468 | m_application.SceneManager.ForEachScene( | ||
400 | delegate(Scene scene) | 469 | delegate(Scene scene) |
401 | { | 470 | { |
402 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 471 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
403 | if (dialogModule != null) | 472 | if (dialogModule != null) |
473 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
474 | }); | ||
475 | } | ||
476 | else | ||
477 | { | ||
478 | if (!requestData.ContainsKey("noticetype") | ||
479 | || ((string)requestData["noticetype"] != "none")) | ||
480 | { | ||
481 | m_application.SceneManager.ForEachScene( | ||
482 | delegate(Scene scene) | ||
483 | { | ||
484 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
485 | if (dialogModule != null) | ||
404 | dialogModule.SendGeneralAlert(message); | 486 | dialogModule.SendGeneralAlert(message); |
405 | }); | 487 | }); |
488 | } | ||
489 | } | ||
490 | |||
491 | |||
406 | 492 | ||
407 | // Perform shutdown | 493 | // Perform shutdown |
408 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 494 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |