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 9400788..87eae1e 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 {
@@ -384,13 +482,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
384 message = "Region is going down now."; 482 message = "Region is going down now.";
385 } 483 }
386 484
387 m_app.SceneManager.ForEachScene( 485 if (requestData.ContainsKey("noticetype")
486 && ((string) requestData["noticetype"] == "dialog"))
487 {
488 m_app.SceneManager.ForEachScene(
388 delegate(Scene scene) 489 delegate(Scene scene)
389 { 490 {
390 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); 491 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
391 if (dialogModule != null) 492 if (dialogModule != null)
493 dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
494 });
495 }
496 else
497 {
498 if (!requestData.ContainsKey("noticetype")
499 || ((string)requestData["noticetype"] != "none"))
500 {
501 m_app.SceneManager.ForEachScene(
502 delegate(Scene scene)
503 {
504 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
505 if (dialogModule != null)
392 dialogModule.SendGeneralAlert(message); 506 dialogModule.SendGeneralAlert(message);
393 }); 507 });
508 }
509 }
510
511
394 512
395 // Perform shutdown 513 // Perform shutdown
396 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing 514 System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing