diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 122 |
1 files changed, 120 insertions, 2 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index c09252a..7b931d7 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 |
@@ -217,9 +218,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
217 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) | 218 | if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) |
218 | throw new Exception("region not found"); | 219 | throw new Exception("region not found"); |
219 | 220 | ||
221 | int timeout = 30000; | ||
222 | string message; | ||
223 | |||
224 | if (requestData.ContainsKey("restart") | ||
225 | && ((string)requestData["restart"] == "delayed") | ||
226 | && requestData.ContainsKey("milliseconds")) | ||
227 | { | ||
228 | timeout = Int32.Parse(requestData["milliseconds"].ToString()); | ||
229 | |||
230 | if (timeout < 15000) | ||
231 | { | ||
232 | //It must be at least 15 seconds or we'll cancel the reboot request | ||
233 | timeout = 15000; | ||
234 | } | ||
235 | |||
236 | message | ||
237 | = "Region is restarting in " + ((int)(timeout / 1000)).ToString() | ||
238 | + " second(s). Please save what you are doing and log out."; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | message = "Region is restarting in 30 second(s). Please save what you are doing and log out."; | ||
243 | } | ||
244 | |||
245 | if (requestData.ContainsKey("noticetype") | ||
246 | && ((string)requestData["noticetype"] == "dialog")) | ||
247 | { | ||
248 | m_application.SceneManager.ForEachScene( | ||
249 | delegate(Scene scene) | ||
250 | { | ||
251 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
252 | if (dialogModule != null) | ||
253 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
254 | }); | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | if (!requestData.ContainsKey("noticetype") | ||
259 | || ((string)requestData["noticetype"] != "none")) | ||
260 | { | ||
261 | m_application.SceneManager.ForEachScene( | ||
262 | delegate(Scene scene) | ||
263 | { | ||
264 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
265 | if (dialogModule != null) | ||
266 | dialogModule.SendGeneralAlert(message); | ||
267 | }); | ||
268 | } | ||
269 | } | ||
270 | |||
220 | responseData["rebooting"] = true; | 271 | responseData["rebooting"] = true; |
221 | response.Value = responseData; | 272 | response.Value = responseData; |
222 | rebootedScene.Restart(30); | 273 | rebootedScene.Restart(timeout / 1000,false); |
223 | } | 274 | } |
224 | catch (Exception e) | 275 | catch (Exception e) |
225 | { | 276 | { |
@@ -282,6 +333,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
282 | m_log.Info("[RADMIN]: Alert request complete"); | 333 | m_log.Info("[RADMIN]: Alert request complete"); |
283 | return response; | 334 | return response; |
284 | } | 335 | } |
336 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
337 | { | ||
338 | XmlRpcResponse response = new XmlRpcResponse(); | ||
339 | Hashtable responseData = new Hashtable(); | ||
340 | |||
341 | m_log.Info("[RADMIN]: Dialog request started"); | ||
342 | |||
343 | try | ||
344 | { | ||
345 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
346 | |||
347 | CheckStringParameters(request, new string[] { "password", "from", "message" }); | ||
348 | |||
349 | if (m_requiredPassword != String.Empty && | ||
350 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
351 | throw new Exception("wrong password"); | ||
352 | |||
353 | string message = (string)requestData["message"]; | ||
354 | string fromuuid = (string)requestData["from"]; | ||
355 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
356 | |||
357 | responseData["accepted"] = true; | ||
358 | responseData["success"] = true; | ||
359 | response.Value = responseData; | ||
360 | |||
361 | m_application.SceneManager.ForEachScene( | ||
362 | delegate(Scene scene) | ||
363 | { | ||
364 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
365 | if (dialogModule != null) | ||
366 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
367 | }); | ||
368 | } | ||
369 | catch (Exception e) | ||
370 | { | ||
371 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
372 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
373 | |||
374 | responseData["accepted"] = false; | ||
375 | responseData["success"] = false; | ||
376 | responseData["error"] = e.Message; | ||
377 | response.Value = responseData; | ||
378 | } | ||
379 | |||
380 | m_log.Info("[RADMIN]: Alert request complete"); | ||
381 | return response; | ||
382 | } | ||
285 | 383 | ||
286 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 384 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
287 | { | 385 | { |
@@ -389,13 +487,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
389 | message = "Region is going down now."; | 487 | message = "Region is going down now."; |
390 | } | 488 | } |
391 | 489 | ||
392 | m_application.SceneManager.ForEachScene( | 490 | if (requestData.ContainsKey("noticetype") |
491 | && ((string) requestData["noticetype"] == "dialog")) | ||
492 | { | ||
493 | m_application.SceneManager.ForEachScene( | ||
393 | delegate(Scene scene) | 494 | delegate(Scene scene) |
394 | { | 495 | { |
395 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 496 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
396 | if (dialogModule != null) | 497 | if (dialogModule != null) |
498 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
499 | }); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | if (!requestData.ContainsKey("noticetype") | ||
504 | || ((string)requestData["noticetype"] != "none")) | ||
505 | { | ||
506 | m_application.SceneManager.ForEachScene( | ||
507 | delegate(Scene scene) | ||
508 | { | ||
509 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
510 | if (dialogModule != null) | ||
397 | dialogModule.SendGeneralAlert(message); | 511 | dialogModule.SendGeneralAlert(message); |
398 | }); | 512 | }); |
513 | } | ||
514 | } | ||
515 | |||
516 | |||
399 | 517 | ||
400 | // Perform shutdown | 518 | // Perform shutdown |
401 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 519 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |