aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-07 20:09:37 +0000
committerJustin Clarke Casey2009-01-07 20:09:37 +0000
commit9b96fc9029b7934743a81b98bfbdfba01e68f2f5 (patch)
treee3af4de31a80d6f44a7101a729d74e0f8d19ff51
parent* Slightly increase ScenePresences locking where it's technically required in... (diff)
downloadopensim-SC-9b96fc9029b7934743a81b98bfbdfba01e68f2f5.zip
opensim-SC-9b96fc9029b7934743a81b98bfbdfba01e68f2f5.tar.gz
opensim-SC-9b96fc9029b7934743a81b98bfbdfba01e68f2f5.tar.bz2
opensim-SC-9b96fc9029b7934743a81b98bfbdfba01e68f2f5.tar.xz
* refactor: Establish DialogModule, move some alert code from Scene to here
-rw-r--r--OpenSim/Region/Environment/Interfaces/IDialogModule.cs59
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Dialog/DialogModule.cs83
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs57
3 files changed, 153 insertions, 46 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IDialogModule.cs b/OpenSim/Region/Environment/Interfaces/IDialogModule.cs
new file mode 100644
index 0000000..15f0471
--- /dev/null
+++ b/OpenSim/Region/Environment/Interfaces/IDialogModule.cs
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30
31namespace OpenSim.Region.Environment.Interfaces
32{
33 public interface IDialogModule
34 {
35 /// <summary>
36 /// Send a non-modal alert message to a particular user.
37 /// </summary>
38 /// <param name="agentID"></param>
39 /// <param name="message"></param>
40 void SendAlertToUser(UUID agentID, string message);
41
42 /// <summary>
43 /// Send an alert message to a particular user.
44 /// </summary>
45 /// <param name="agentID"></param>
46 /// <param name="message"></param>
47 /// <param name="modal"></param>
48 void SendAlertToUser(UUID agentID, string message, bool modal);
49
50 /// <summary>
51 /// Send an alert message to a particular user.
52 /// </summary>
53 /// <param name="firstName"></param>
54 /// <param name="lastName"></param>
55 /// <param name="message"></param>
56 /// <param name="modal"></param>
57 void SendAlertToUser(string firstName, string lastName, string message, bool modal);
58 }
59}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Dialog/DialogModule.cs
new file mode 100644
index 0000000..e036c73
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Avatar/Dialog/DialogModule.cs
@@ -0,0 +1,83 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using System.Reflection;
30using log4net;
31using Nini.Config;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes;
36
37namespace OpenSim.Region.Environment.Modules.Avatar.Dialog
38{
39 public class DialogModule : IRegionModule, IDialogModule
40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 protected Scene m_scene;
44
45 public void Initialise(Scene scene, IConfigSource source)
46 {
47 m_scene = scene;
48 m_scene.RegisterModuleInterface<IDialogModule>(this);
49 }
50
51 public void PostInitialise() {}
52 public void Close() {}
53 public string Name { get { return "Dialog Module"; } }
54 public bool IsSharedModule { get { return false; } }
55
56 public void SendAlertToUser(UUID agentID, string message)
57 {
58 SendAlertToUser(agentID, message, false);
59 }
60
61 public void SendAlertToUser(UUID agentID, string message, bool modal)
62 {
63 ScenePresence sp = m_scene.GetScenePresence(agentID);
64
65 if (sp != null)
66 sp.ControllingClient.SendAgentAlertMessage(message, modal);
67 }
68
69 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
70 {
71 List<ScenePresence> presenceList = m_scene.GetScenePresences();
72
73 foreach (ScenePresence presence in presenceList)
74 {
75 if (presence.Firstname == firstName && presence.Lastname == lastName)
76 {
77 presence.ControllingClient.SendAgentAlertMessage(message, modal);
78 break;
79 }
80 }
81 }
82 }
83}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 9a07f6b..c3f2417 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -414,7 +414,10 @@ namespace OpenSim.Region.Environment.Scenes
414 414
415 protected virtual void RegisterDefaultSceneEvents() 415 protected virtual void RegisterDefaultSceneEvents()
416 { 416 {
417 m_eventManager.OnPermissionError += SendPermissionAlert; 417 IDialogModule dm = RequestModuleInterface<IDialogModule>();
418
419 if (dm != null)
420 m_eventManager.OnPermissionError += dm.SendAlertToUser;
418 } 421 }
419 422
420 public override string GetSimulatorVersion() 423 public override string GetSimulatorVersion()
@@ -3429,11 +3432,6 @@ namespace OpenSim.Region.Environment.Scenes
3429 3432
3430 #region Alert Methods 3433 #region Alert Methods
3431 3434
3432 private void SendPermissionAlert(UUID user, string reason)
3433 {
3434 SendAlertToUser(user, reason, false);
3435 }
3436
3437 /// <summary> 3435 /// <summary>
3438 /// Send an alert messages to all avatars in this scene. 3436 /// Send an alert messages to all avatars in this scene.
3439 /// </summary> 3437 /// </summary>
@@ -3450,23 +3448,6 @@ namespace OpenSim.Region.Environment.Scenes
3450 } 3448 }
3451 3449
3452 /// <summary> 3450 /// <summary>
3453 /// Send an alert message to a particular agent.
3454 /// </summary>
3455 /// <param name="agentID"></param>
3456 /// <param name="message"></param>
3457 /// <param name="modal"></param>
3458 public void SendAlertToUser(UUID agentID, string message, bool modal)
3459 {
3460 lock (m_scenePresences)
3461 {
3462 if (m_scenePresences.ContainsKey(agentID))
3463 {
3464 m_scenePresences[agentID].ControllingClient.SendAgentAlertMessage(message, modal);
3465 }
3466 }
3467 }
3468
3469 /// <summary>
3470 /// Handle a request for admin rights 3451 /// Handle a request for admin rights
3471 /// </summary> 3452 /// </summary>
3472 /// <param name="agentID"></param> 3453 /// <param name="agentID"></param>
@@ -3626,27 +3607,6 @@ namespace OpenSim.Region.Environment.Scenes
3626 } 3607 }
3627 3608
3628 /// <summary> 3609 /// <summary>
3629 ///
3630 /// </summary>
3631 /// <param name="firstName"></param>
3632 /// <param name="lastName"></param>
3633 /// <param name="message"></param>
3634 /// <param name="modal"></param>
3635 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
3636 {
3637 List<ScenePresence> presenceList = GetScenePresences();
3638
3639 foreach (ScenePresence presence in presenceList)
3640 {
3641 if (presence.Firstname == firstName && presence.Lastname == lastName)
3642 {
3643 presence.ControllingClient.SendAgentAlertMessage(message, modal);
3644 break;
3645 }
3646 }
3647 }
3648
3649 /// <summary>
3650 /// Handle an alert command from the console. 3610 /// Handle an alert command from the console.
3651 /// FIXME: Command parsing code really shouldn't be in this core Scene class. 3611 /// FIXME: Command parsing code really shouldn't be in this core Scene class.
3652 /// </summary> 3612 /// </summary>
@@ -3660,8 +3620,13 @@ namespace OpenSim.Region.Environment.Scenes
3660 } 3620 }
3661 else 3621 else
3662 { 3622 {
3663 string message = CombineParams(commandParams, 2); 3623 IDialogModule dm = RequestModuleInterface<IDialogModule>();
3664 SendAlertToUser(commandParams[0], commandParams[1], message, false); 3624
3625 if (dm != null)
3626 {
3627 string message = CombineParams(commandParams, 2);
3628 dm.SendAlertToUser(commandParams[0], commandParams[1], message, false);
3629 }
3665 } 3630 }
3666 } 3631 }
3667 3632