aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Dialog
diff options
context:
space:
mode:
authormeta72010-08-07 08:17:11 -0700
committermeta72010-08-07 08:17:11 -0700
commit19debab060b246f61d633b06d926a068001f6510 (patch)
tree56b32c11f013e07d5ab2b29fda9426aa868d32ca /OpenSim/Region/CoreModules/Avatar/Dialog
parentAdd some nullref checks to the UnackedPacketCollection. (diff)
downloadopensim-SC_OLD-19debab060b246f61d633b06d926a068001f6510.zip
opensim-SC_OLD-19debab060b246f61d633b06d926a068001f6510.tar.gz
opensim-SC_OLD-19debab060b246f61d633b06d926a068001f6510.tar.bz2
opensim-SC_OLD-19debab060b246f61d633b06d926a068001f6510.tar.xz
Fix the general alert message so it doesn't get sent to child agents
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Dialog')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs443
1 files changed, 223 insertions, 220 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index fb0bd1a..1498dba 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -1,220 +1,223 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35 35
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39 39
40namespace OpenSim.Region.CoreModules.Avatar.Dialog 40namespace OpenSim.Region.CoreModules.Avatar.Dialog
41{ 41{
42 public class DialogModule : IRegionModule, IDialogModule 42 public class DialogModule : IRegionModule, IDialogModule
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected Scene m_scene; 46 protected Scene m_scene;
47 47
48 public void Initialise(Scene scene, IConfigSource source) 48 public void Initialise(Scene scene, IConfigSource source)
49 { 49 {
50 m_scene = scene; 50 m_scene = scene;
51 m_scene.RegisterModuleInterface<IDialogModule>(this); 51 m_scene.RegisterModuleInterface<IDialogModule>(this);
52 52
53 m_scene.AddCommand( 53 m_scene.AddCommand(
54 this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand); 54 this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand);
55 55
56 m_scene.AddCommand( 56 m_scene.AddCommand(
57 this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand); 57 this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand);
58 58
59 m_scene.AddCommand( 59 m_scene.AddCommand(
60 this, "alert dialog", "alert dialog <message>", "Send a dialog alert to everyone", HandleAlertConsoleCommand); 60 this, "alert dialog", "alert dialog <message>", "Send a dialog alert to everyone", HandleAlertConsoleCommand);
61 61
62 62
63 } 63 }
64 64
65 public void PostInitialise() {} 65 public void PostInitialise() {}
66 public void Close() {} 66 public void Close() {}
67 public string Name { get { return "Dialog Module"; } } 67 public string Name { get { return "Dialog Module"; } }
68 public bool IsSharedModule { get { return false; } } 68 public bool IsSharedModule { get { return false; } }
69 69
70 public void SendAlertToUser(IClientAPI client, string message) 70 public void SendAlertToUser(IClientAPI client, string message)
71 { 71 {
72 SendAlertToUser(client, message, false); 72 SendAlertToUser(client, message, false);
73 } 73 }
74 74
75 public void SendAlertToUser(IClientAPI client, string message, bool modal) 75 public void SendAlertToUser(IClientAPI client, string message, bool modal)
76 { 76 {
77 client.SendAgentAlertMessage(message, modal); 77 client.SendAgentAlertMessage(message, modal);
78 } 78 }
79 79
80 public void SendAlertToUser(UUID agentID, string message) 80 public void SendAlertToUser(UUID agentID, string message)
81 { 81 {
82 SendAlertToUser(agentID, message, false); 82 SendAlertToUser(agentID, message, false);
83 } 83 }
84 84
85 public void SendAlertToUser(UUID agentID, string message, bool modal) 85 public void SendAlertToUser(UUID agentID, string message, bool modal)
86 { 86 {
87 ScenePresence sp = m_scene.GetScenePresence(agentID); 87 ScenePresence sp = m_scene.GetScenePresence(agentID);
88 88
89 if (sp != null) 89 if (sp != null)
90 sp.ControllingClient.SendAgentAlertMessage(message, modal); 90 sp.ControllingClient.SendAgentAlertMessage(message, modal);
91 } 91 }
92 92
93 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 93 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
94 { 94 {
95 ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); 95 ScenePresence presence = m_scene.GetScenePresence(firstName, lastName);
96 if (presence != null) 96 if (presence != null)
97 presence.ControllingClient.SendAgentAlertMessage(message, modal); 97 presence.ControllingClient.SendAgentAlertMessage(message, modal);
98 } 98 }
99 99
100 public void SendGeneralAlert(string message) 100 public void SendGeneralAlert(string message)
101 { 101 {
102 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 102 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
103 { 103 {
104 presence.ControllingClient.SendAlertMessage(message); 104 if (!presence.IsChildAgent)
105 }); 105 {
106 } 106 presence.ControllingClient.SendAlertMessage(message);
107 107 }
108 public void SendDialogToUser( 108 });
109 UUID avatarID, string objectName, UUID objectID, UUID ownerID, 109 }
110 string message, UUID textureID, int ch, string[] buttonlabels) 110
111 { 111 public void SendDialogToUser(
112 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); 112 UUID avatarID, string objectName, UUID objectID, UUID ownerID,
113 string ownerFirstName, ownerLastName; 113 string message, UUID textureID, int ch, string[] buttonlabels)
114 if (account != null) 114 {
115 { 115 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID);
116 ownerFirstName = account.FirstName; 116 string ownerFirstName, ownerLastName;
117 ownerLastName = account.LastName; 117 if (account != null)
118 } 118 {
119 else 119 ownerFirstName = account.FirstName;
120 { 120 ownerLastName = account.LastName;
121 ownerFirstName = "(unknown"; 121 }
122 ownerLastName = "user)"; 122 else
123 } 123 {
124 124 ownerFirstName = "(unknown";
125 ScenePresence sp = m_scene.GetScenePresence(avatarID); 125 ownerLastName = "user)";
126 if (sp != null) 126 }
127 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); 127
128 } 128 ScenePresence sp = m_scene.GetScenePresence(avatarID);
129 129 if (sp != null)
130 public void SendUrlToUser( 130 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
131 UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) 131 }
132 { 132
133 ScenePresence sp = m_scene.GetScenePresence(avatarID); 133 public void SendUrlToUser(
134 134 UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
135 if (sp != null) 135 {
136 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); 136 ScenePresence sp = m_scene.GetScenePresence(avatarID);
137 } 137
138 138 if (sp != null)
139 public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) 139 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url);
140 { 140 }
141 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); 141
142 string ownerFirstName, ownerLastName; 142 public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid)
143 if (account != null) 143 {
144 { 144 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid);
145 ownerFirstName = account.FirstName; 145 string ownerFirstName, ownerLastName;
146 ownerLastName = account.LastName; 146 if (account != null)
147 } 147 {
148 else 148 ownerFirstName = account.FirstName;
149 { 149 ownerLastName = account.LastName;
150 ownerFirstName = "(unknown"; 150 }
151 ownerLastName = "user)"; 151 else
152 } 152 {
153 153 ownerFirstName = "(unknown";
154 ScenePresence sp = m_scene.GetScenePresence(avatarid); 154 ownerLastName = "user)";
155 155 }
156 if (sp != null) 156
157 sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid); 157 ScenePresence sp = m_scene.GetScenePresence(avatarid);
158 } 158
159 159 if (sp != null)
160 public void SendNotificationToUsersInRegion( 160 sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerFirstName, ownerLastName, objectid);
161 UUID fromAvatarID, string fromAvatarName, string message) 161 }
162 { 162
163 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 163 public void SendNotificationToUsersInRegion(
164 { 164 UUID fromAvatarID, string fromAvatarName, string message)
165 if (!presence.IsChildAgent) 165 {
166 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); 166 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
167 }); 167 {
168 } 168 if (!presence.IsChildAgent)
169 169 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
170 /// <summary> 170 });
171 /// Handle an alert command from the console. 171 }
172 /// </summary> 172
173 /// <param name="module"></param> 173 /// <summary>
174 /// <param name="cmdparams"></param> 174 /// Handle an alert command from the console.
175 public void HandleAlertConsoleCommand(string module, string[] cmdparams) 175 /// </summary>
176 { 176 /// <param name="module"></param>
177 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) 177 /// <param name="cmdparams"></param>
178 return; 178 public void HandleAlertConsoleCommand(string module, string[] cmdparams)
179 179 {
180 if (cmdparams[1] == "general") 180 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
181 { 181 return;
182 string message = CombineParams(cmdparams, 2); 182
183 183 if (cmdparams[1] == "general")
184 m_log.InfoFormat( 184 {
185 "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); 185 string message = CombineParams(cmdparams, 2);
186 SendGeneralAlert(message); 186
187 } 187 m_log.InfoFormat(
188 else if (cmdparams[1] == "dialog") 188 "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
189 { 189 SendGeneralAlert(message);
190 string message = CombineParams(cmdparams, 2); 190 }
191 191 else if (cmdparams[1] == "dialog")
192 m_log.InfoFormat( 192 {
193 "[DIALOG]: Sending dialog alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); 193 string message = CombineParams(cmdparams, 2);
194 SendNotificationToUsersInRegion(UUID.Zero, "System", message); 194
195 } 195 m_log.InfoFormat(
196 else 196 "[DIALOG]: Sending dialog alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
197 { 197 SendNotificationToUsersInRegion(UUID.Zero, "System", message);
198 string firstName = cmdparams[1]; 198 }
199 string lastName = cmdparams[2]; 199 else
200 string message = CombineParams(cmdparams, 3); 200 {
201 201 string firstName = cmdparams[1];
202 m_log.InfoFormat( 202 string lastName = cmdparams[2];
203 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", 203 string message = CombineParams(cmdparams, 3);
204 m_scene.RegionInfo.RegionName, firstName, lastName, message); 204
205 SendAlertToUser(firstName, lastName, message, false); 205 m_log.InfoFormat(
206 } 206 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
207 } 207 m_scene.RegionInfo.RegionName, firstName, lastName, message);
208 208 SendAlertToUser(firstName, lastName, message, false);
209 private string CombineParams(string[] commandParams, int pos) 209 }
210 { 210 }
211 string result = string.Empty; 211
212 for (int i = pos; i < commandParams.Length; i++) 212 private string CombineParams(string[] commandParams, int pos)
213 { 213 {
214 result += commandParams[i] + " "; 214 string result = string.Empty;
215 } 215 for (int i = pos; i < commandParams.Length; i++)
216 216 {
217 return result; 217 result += commandParams[i] + " ";
218 } 218 }
219 } 219
220} 220 return result;
221 }
222 }
223}