aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-13 19:03:18 +0000
committerJustin Clarke Casey2009-02-13 19:03:18 +0000
commitd307109e1af20c5b1b27743853236d7842d871f0 (patch)
tree200d85452cadddc5b05ab90e311c2b373ec9d1b7
parent* Quieten down log messages from the Friends module (diff)
downloadopensim-SC_OLD-d307109e1af20c5b1b27743853236d7842d871f0.zip
opensim-SC_OLD-d307109e1af20c5b1b27743853236d7842d871f0.tar.gz
opensim-SC_OLD-d307109e1af20c5b1b27743853236d7842d871f0.tar.bz2
opensim-SC_OLD-d307109e1af20c5b1b27743853236d7842d871f0.tar.xz
* refactor: move alert commands from Scene to DialogModule
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs36
-rw-r--r--OpenSim/Region/Application/OpenSim.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs52
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs10
5 files changed, 78 insertions, 63 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index d457d2b..a0f1eea 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -182,7 +182,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
182 XmlRpcResponse response = new XmlRpcResponse(); 182 XmlRpcResponse response = new XmlRpcResponse();
183 Hashtable responseData = new Hashtable(); 183 Hashtable responseData = new Hashtable();
184 184
185 try { 185 try
186 {
186 Hashtable requestData = (Hashtable) request.Params[0]; 187 Hashtable requestData = (Hashtable) request.Params[0];
187 188
188 checkStringParameters(request, new string[] { "password", "message" }); 189 checkStringParameters(request, new string[] { "password", "message" });
@@ -197,8 +198,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
197 responseData["accepted"] = "true"; 198 responseData["accepted"] = "true";
198 responseData["success"] = "true"; 199 responseData["success"] = "true";
199 response.Value = responseData; 200 response.Value = responseData;
200 201
201 m_app.SceneManager.SendGeneralMessage(message); 202 m_app.SceneManager.ForEachScene(
203 delegate(Scene scene)
204 {
205 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
206 if (dialogModule != null)
207 dialogModule.SendGeneralAlert(message);
208 });
202 } 209 }
203 catch(Exception e) 210 catch(Exception e)
204 { 211 {
@@ -283,19 +290,30 @@ namespace OpenSim.ApplicationPlugins.RemoteController
283 response.Value = responseData; 290 response.Value = responseData;
284 291
285 int timeout = 2000; 292 int timeout = 2000;
293 string message;
286 294
287 if (requestData.ContainsKey("shutdown") && 295 if (requestData.ContainsKey("shutdown")
288 ((string) requestData["shutdown"] == "delayed") && 296 && ((string) requestData["shutdown"] == "delayed")
289 requestData.ContainsKey("milliseconds")) 297 && requestData.ContainsKey("milliseconds"))
290 { 298 {
291 timeout = (Int32) requestData["milliseconds"]; 299 timeout = (Int32) requestData["milliseconds"];
292 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() + 300
293 " second(s). Please save what you are doing and log out."); 301 message
302 = "Region is going down in " + ((int) (timeout/1000)).ToString()
303 + " second(s). Please save what you are doing and log out.";
294 } 304 }
295 else 305 else
296 { 306 {
297 m_app.SceneManager.SendGeneralMessage("Region is going down now."); 307 message = "Region is going down now.";
298 } 308 }
309
310 m_app.SceneManager.ForEachScene(
311 delegate(Scene scene)
312 {
313 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
314 if (dialogModule != null)
315 dialogModule.SendGeneralAlert(message);
316 });
299 317
300 // Perform shutdown 318 // Perform shutdown
301 Timer shutdownTimer = new Timer(timeout); // Wait before firing 319 Timer shutdownTimer = new Timer(timeout); // Wait before firing
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 17ced08..a0d5bd8 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -177,14 +177,6 @@ namespace OpenSim
177 "show queues", 177 "show queues",
178 "Show queue data", HandleShow); 178 "Show queue data", HandleShow);
179 179
180 m_console.Commands.AddCommand("region", false, "alert",
181 "alert <first> <last> <message>",
182 "Send an alert to a user", RunCommand);
183
184 m_console.Commands.AddCommand("region", false, "alert general",
185 "alert general <message>",
186 "Send an alert everyone", RunCommand);
187
188 m_console.Commands.AddCommand("region", false, "backup", 180 m_console.Commands.AddCommand("region", false, "backup",
189 "backup", 181 "backup",
190 "Persist objects to the database now", RunCommand); 182 "Persist objects to the database now", RunCommand);
@@ -547,7 +539,6 @@ namespace OpenSim
547 } 539 }
548 } 540 }
549 541
550
551 /// <summary> 542 /// <summary>
552 /// Runs commands issued by the server console from the operator 543 /// Runs commands issued by the server console from the operator
553 /// </summary> 544 /// </summary>
@@ -577,10 +568,6 @@ namespace OpenSim
577 m_sceneManager.BackupCurrentScene(); 568 m_sceneManager.BackupCurrentScene();
578 break; 569 break;
579 570
580 case "alert":
581 m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams);
582 break;
583
584 case "remove-region": 571 case "remove-region":
585 string regRemoveName = CombineParams(cmdparams, 0); 572 string regRemoveName = CombineParams(cmdparams, 0);
586 573
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 3fe57bc..6dd020a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -26,6 +26,8 @@
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection;
30using log4net;
29using Nini.Config; 31using Nini.Config;
30using OpenMetaverse; 32using OpenMetaverse;
31using OpenSim.Framework; 33using OpenSim.Framework;
@@ -36,7 +38,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
36{ 38{
37 public class DialogModule : IRegionModule, IDialogModule 39 public class DialogModule : IRegionModule, IDialogModule
38 { 40 {
39 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 42
41 protected Scene m_scene; 43 protected Scene m_scene;
42 44
@@ -44,6 +46,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
44 { 46 {
45 m_scene = scene; 47 m_scene = scene;
46 m_scene.RegisterModuleInterface<IDialogModule>(this); 48 m_scene.RegisterModuleInterface<IDialogModule>(this);
49
50 m_scene.AddCommand(
51 this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand);
52
53 m_scene.AddCommand(
54 this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand);
47 } 55 }
48 56
49 public void PostInitialise() {} 57 public void PostInitialise() {}
@@ -137,5 +145,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
137 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); 145 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
138 } 146 }
139 } 147 }
148
149 /// <summary>
150 /// Handle an alert command from the console.
151 /// </summary>
152 /// <param name="module"></param>
153 /// <param name="cmdparams"></param>
154 public void HandleAlertConsoleCommand(string module, string[] cmdparams)
155 {
156 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
157 return;
158
159 if (cmdparams[1] == "general")
160 {
161 string message = CombineParams(cmdparams, 2);
162
163 m_log.InfoFormat(
164 "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
165 SendGeneralAlert(message);
166 }
167 else
168 {
169 string firstName = cmdparams[1];
170 string lastName = cmdparams[2];
171 string message = CombineParams(cmdparams, 3);
172
173 m_log.InfoFormat(
174 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
175 m_scene.RegionInfo.RegionName, firstName, lastName, message);
176 SendAlertToUser(firstName, lastName, message, false);
177 }
178 }
179
180 private string CombineParams(string[] commandParams, int pos)
181 {
182 string result = string.Empty;
183 for (int i = pos; i < commandParams.Length; i++)
184 {
185 result += commandParams[i] + " ";
186 }
187
188 return result;
189 }
140 } 190 }
141} 191}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 18e729f..611b9db 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2213,7 +2213,6 @@ namespace OpenSim.Region.Framework.Scenes
2213 { 2213 {
2214 lock (av) 2214 lock (av)
2215 { 2215 {
2216
2217 for (int i = 0; i < regionslst.Count; i++) 2216 for (int i = 0; i < regionslst.Count; i++)
2218 { 2217 {
2219 av.KnownChildRegionHandles.Remove(regionslst[i]); 2218 av.KnownChildRegionHandles.Remove(regionslst[i]);
@@ -2902,35 +2901,6 @@ namespace OpenSim.Region.Framework.Scenes
2902 } 2901 }
2903 } 2902 }
2904 2903
2905 /// <summary>
2906 /// Handle an alert command from the console.
2907 /// FIXME: Command parsing code really shouldn't be in this core Scene class.
2908 /// </summary>
2909 /// <param name="commandParams"></param>
2910 public void HandleAlertCommand(string[] commandParams)
2911 {
2912 if (commandParams[0] == "general")
2913 {
2914 string message = CombineParams(commandParams, 1);
2915 m_dialogModule.SendGeneralAlert(message);
2916 }
2917 else
2918 {
2919 string message = CombineParams(commandParams, 2);
2920 m_dialogModule.SendAlertToUser(commandParams[0], commandParams[1], message, false);
2921 }
2922 }
2923
2924 private string CombineParams(string[] commandParams, int pos)
2925 {
2926 string result = String.Empty;
2927 for (int i = pos; i < commandParams.Length; i++)
2928 {
2929 result += commandParams[i] + " ";
2930 }
2931 return result;
2932 }
2933
2934 #endregion 2904 #endregion
2935 2905
2936 /// <summary> 2906 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 180f8a1..fe37dae 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -296,16 +296,6 @@ namespace OpenSim.Region.Framework.Scenes
296 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); 296 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
297 } 297 }
298 298
299 public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
300 {
301 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
302 }
303
304 public void SendGeneralMessage(string msg)
305 {
306 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(new string[] { "general", msg }); });
307 }
308
309 public bool TrySetCurrentScene(string regionName) 299 public bool TrySetCurrentScene(string regionName)
310 { 300 {
311 if ((String.Compare(regionName, "root") == 0) 301 if ((String.Compare(regionName, "root") == 0)