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 3149eaa..325816d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -123,6 +123,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
123 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; | 123 | availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; |
124 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; | 124 | availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; |
125 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; | 125 | availableMethods["admin_broadcast"] = XmlRpcAlertMethod; |
126 | availableMethods["admin_dialog"] = XmlRpcDialogMethod; | ||
126 | availableMethods["admin_restart"] = XmlRpcRestartMethod; | 127 | availableMethods["admin_restart"] = XmlRpcRestartMethod; |
127 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; | 128 | availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; |
128 | // User management | 129 | // User management |
@@ -212,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
212 | if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) | 213 | if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) |
213 | throw new Exception("region not found"); | 214 | throw new Exception("region not found"); |
214 | 215 | ||
216 | int timeout = 30000; | ||
217 | string message; | ||
218 | |||
219 | if (requestData.ContainsKey("restart") | ||
220 | && ((string)requestData["restart"] == "delayed") | ||
221 | && requestData.ContainsKey("milliseconds")) | ||
222 | { | ||
223 | timeout = Int32.Parse(requestData["milliseconds"].ToString()); | ||
224 | |||
225 | if (timeout < 15000) | ||
226 | { | ||
227 | //It must be at least 15 seconds or we'll cancel the reboot request | ||
228 | timeout = 15000; | ||
229 | } | ||
230 | |||
231 | message | ||
232 | = "Region is restarting in " + ((int)(timeout / 1000)).ToString() | ||
233 | + " second(s). Please save what you are doing and log out."; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | message = "Region is restarting in 30 second(s). Please save what you are doing and log out."; | ||
238 | } | ||
239 | |||
240 | if (requestData.ContainsKey("noticetype") | ||
241 | && ((string)requestData["noticetype"] == "dialog")) | ||
242 | { | ||
243 | m_app.SceneManager.ForEachScene( | ||
244 | delegate(Scene scene) | ||
245 | { | ||
246 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
247 | if (dialogModule != null) | ||
248 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
249 | }); | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | if (!requestData.ContainsKey("noticetype") | ||
254 | || ((string)requestData["noticetype"] != "none")) | ||
255 | { | ||
256 | m_app.SceneManager.ForEachScene( | ||
257 | delegate(Scene scene) | ||
258 | { | ||
259 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
260 | if (dialogModule != null) | ||
261 | dialogModule.SendGeneralAlert(message); | ||
262 | }); | ||
263 | } | ||
264 | } | ||
265 | |||
215 | responseData["rebooting"] = true; | 266 | responseData["rebooting"] = true; |
216 | response.Value = responseData; | 267 | response.Value = responseData; |
217 | rebootedScene.Restart(30); | 268 | rebootedScene.Restart(timeout / 1000,false); |
218 | } | 269 | } |
219 | catch (Exception e) | 270 | catch (Exception e) |
220 | { | 271 | { |
@@ -277,6 +328,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
277 | m_log.Info("[RADMIN]: Alert request complete"); | 328 | m_log.Info("[RADMIN]: Alert request complete"); |
278 | return response; | 329 | return response; |
279 | } | 330 | } |
331 | public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) | ||
332 | { | ||
333 | XmlRpcResponse response = new XmlRpcResponse(); | ||
334 | Hashtable responseData = new Hashtable(); | ||
335 | |||
336 | m_log.Info("[RADMIN]: Dialog request started"); | ||
337 | |||
338 | try | ||
339 | { | ||
340 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
341 | |||
342 | checkStringParameters(request, new string[] { "password", "from", "message" }); | ||
343 | |||
344 | if (m_requiredPassword != String.Empty && | ||
345 | (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) | ||
346 | throw new Exception("wrong password"); | ||
347 | |||
348 | string message = (string)requestData["message"]; | ||
349 | string fromuuid = (string)requestData["from"]; | ||
350 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
351 | |||
352 | responseData["accepted"] = true; | ||
353 | responseData["success"] = true; | ||
354 | response.Value = responseData; | ||
355 | |||
356 | m_app.SceneManager.ForEachScene( | ||
357 | delegate(Scene scene) | ||
358 | { | ||
359 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
360 | if (dialogModule != null) | ||
361 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); | ||
362 | }); | ||
363 | } | ||
364 | catch (Exception e) | ||
365 | { | ||
366 | m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); | ||
367 | m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); | ||
368 | |||
369 | responseData["accepted"] = false; | ||
370 | responseData["success"] = false; | ||
371 | responseData["error"] = e.Message; | ||
372 | response.Value = responseData; | ||
373 | } | ||
374 | |||
375 | m_log.Info("[RADMIN]: Alert request complete"); | ||
376 | return response; | ||
377 | } | ||
280 | 378 | ||
281 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) | 379 | public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) |
282 | { | 380 | { |
@@ -371,13 +469,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
371 | message = "Region is going down now."; | 469 | message = "Region is going down now."; |
372 | } | 470 | } |
373 | 471 | ||
374 | m_app.SceneManager.ForEachScene( | 472 | if (requestData.ContainsKey("noticetype") |
473 | && ((string) requestData["noticetype"] == "dialog")) | ||
474 | { | ||
475 | m_app.SceneManager.ForEachScene( | ||
375 | delegate(Scene scene) | 476 | delegate(Scene scene) |
376 | { | 477 | { |
377 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | 478 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); |
378 | if (dialogModule != null) | 479 | if (dialogModule != null) |
480 | dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); | ||
481 | }); | ||
482 | } | ||
483 | else | ||
484 | { | ||
485 | if (!requestData.ContainsKey("noticetype") | ||
486 | || ((string)requestData["noticetype"] != "none")) | ||
487 | { | ||
488 | m_app.SceneManager.ForEachScene( | ||
489 | delegate(Scene scene) | ||
490 | { | ||
491 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
492 | if (dialogModule != null) | ||
379 | dialogModule.SendGeneralAlert(message); | 493 | dialogModule.SendGeneralAlert(message); |
380 | }); | 494 | }); |
495 | } | ||
496 | } | ||
497 | |||
498 | |||
381 | 499 | ||
382 | // Perform shutdown | 500 | // Perform shutdown |
383 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing | 501 | System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing |