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