diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 113 |
1 files changed, 108 insertions, 5 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 1b4d1ea..f3f79bc 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 | { |
@@ -289,6 +325,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
289 | m_log.Info("[RADMIN]: Alert request complete"); | 325 | m_log.Info("[RADMIN]: Alert request complete"); |
290 | return response; | 326 | return response; |
291 | } | 327 | } |
328 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
329 | { | ||
330 | XmlRpcResponse response = new XmlRpcResponse(); | ||
331 | Hashtable responseData = new Hashtable(); | ||
332 | |||
333 | m_log.Info("[RADMIN]: Dialog request started"); | ||
334 | |||
335 | try | ||
336 | { | ||
337 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
338 | |||
339 | CheckStringParameters(request, new string[] { "password", "from", "message" }); | ||
340 | |||
341 | if (m_requiredPassword != String.Empty && | ||
342 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
343 | throw new Exception("wrong password"); | ||
344 | |||
345 | string message = (string)requestData["message"]; | ||
346 | string fromuuid = (string)requestData["from"]; | ||
347 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
348 | |||
349 | responseData["accepted"] = true; | ||
350 | responseData["success"] = true; | ||
351 | response.Value = responseData; | ||
352 | |||
353 | m_application.SceneManager.ForEachScene( | ||
354 | delegate(Scene scene) | ||
355 | { | ||
356 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
357 | if (dialogModule != null) | ||
358 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
359 | }); | ||
360 | } | ||
361 | catch (Exception e) | ||
362 | { | ||
363 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
364 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
365 | |||
366 | responseData["accepted"] = false; | ||
367 | responseData["success"] = false; | ||
368 | responseData["error"] = e.Message; | ||
369 | response.Value = responseData; | ||
370 | } | ||
371 | |||
372 | m_log.Info("[RADMIN]: Alert request complete"); | ||
373 | return response; | ||
374 | } | ||
292 | 375 | ||
293 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 376 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
294 | { | 377 | { |
@@ -396,13 +479,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
396 | message = "Region is going down now."; | 479 | message = "Region is going down now."; |
397 | } | 480 | } |
398 | 481 | ||
399 | m_application.SceneManager.ForEachScene( | 482 | if (requestData.ContainsKey("noticetype") |
483 | && ((string) requestData["noticetype"] == "dialog")) | ||
484 | { | ||
485 | m_application.SceneManager.ForEachScene( | ||
400 | delegate(Scene scene) | 486 | delegate(Scene scene) |
401 | { | 487 | { |
402 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 488 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
403 | if (dialogModule != null) | 489 | if (dialogModule != null) |
490 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
491 | }); | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | if (!requestData.ContainsKey("noticetype") | ||
496 | || ((string)requestData["noticetype"] != "none")) | ||
497 | { | ||
498 | m_application.SceneManager.ForEachScene( | ||
499 | delegate(Scene scene) | ||
500 | { | ||
501 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
502 | if (dialogModule != null) | ||
404 | dialogModule.SendGeneralAlert(message); | 503 | dialogModule.SendGeneralAlert(message); |
405 | }); | 504 | }); |
505 | } | ||
506 | } | ||
507 | |||
508 | |||
406 | 509 | ||
407 | // Perform shutdown | 510 | // Perform shutdown |
408 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 511 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |