diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Dialog')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | 144 |
1 files changed, 94 insertions, 50 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 3c294bb..db5a788 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -32,6 +32,7 @@ using log4net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
@@ -39,16 +40,27 @@ using OpenSim.Services.Interfaces; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Dialog | 41 | namespace OpenSim.Region.CoreModules.Avatar.Dialog |
41 | { | 42 | { |
42 | public class DialogModule : IRegionModule, IDialogModule | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
43 | { | 44 | public class DialogModule : IDialogModule, INonSharedRegionModule |
45 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | protected Scene m_scene; | 48 | protected Scene m_scene; |
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 50 | public void Initialise(IConfigSource source) { } |
51 | |||
52 | public Type ReplaceableInterface { get { return null; } } | ||
53 | |||
54 | public void AddRegion(Scene scene) | ||
49 | { | 55 | { |
50 | m_scene = scene; | 56 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IDialogModule>(this); | 57 | m_scene.RegisterModuleInterface<IDialogModule>(this); |
58 | } | ||
59 | |||
60 | public void RegionLoaded(Scene scene) | ||
61 | { | ||
62 | if (scene != m_scene) | ||
63 | return; | ||
52 | 64 | ||
53 | m_scene.AddCommand( | 65 | m_scene.AddCommand( |
54 | "Users", this, "alert", "alert <message>", | 66 | "Users", this, "alert", "alert <message>", |
@@ -56,46 +68,59 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
56 | HandleAlertConsoleCommand); | 68 | HandleAlertConsoleCommand); |
57 | 69 | ||
58 | m_scene.AddCommand( | 70 | m_scene.AddCommand( |
59 | "Users", this, "alert-user", "alert-user <first> <last> <message>", | 71 | "Users", this, "alert-user", |
72 | "alert-user <first> <last> <message>", | ||
60 | "Send an alert to a user", | 73 | "Send an alert to a user", |
61 | HandleAlertConsoleCommand); | 74 | HandleAlertConsoleCommand); |
62 | } | 75 | } |
63 | 76 | ||
64 | public void PostInitialise() {} | 77 | public void RemoveRegion(Scene scene) |
65 | public void Close() {} | 78 | { |
79 | if (scene != m_scene) | ||
80 | return; | ||
81 | |||
82 | m_scene.UnregisterModuleInterface<IDialogModule>(this); | ||
83 | } | ||
84 | |||
85 | public void Close() { } | ||
66 | public string Name { get { return "Dialog Module"; } } | 86 | public string Name { get { return "Dialog Module"; } } |
67 | public bool IsSharedModule { get { return false; } } | 87 | |
68 | |||
69 | public void SendAlertToUser(IClientAPI client, string message) | 88 | public void SendAlertToUser(IClientAPI client, string message) |
70 | { | 89 | { |
71 | SendAlertToUser(client, message, false); | 90 | SendAlertToUser(client, message, false); |
72 | } | 91 | } |
73 | 92 | ||
74 | public void SendAlertToUser(IClientAPI client, string message, bool modal) | 93 | public void SendAlertToUser(IClientAPI client, string message, |
94 | bool modal) | ||
75 | { | 95 | { |
76 | client.SendAgentAlertMessage(message, modal); | 96 | client.SendAgentAlertMessage(message, modal); |
77 | } | 97 | } |
78 | 98 | ||
79 | public void SendAlertToUser(UUID agentID, string message) | 99 | public void SendAlertToUser(UUID agentID, string message) |
80 | { | 100 | { |
81 | SendAlertToUser(agentID, message, false); | 101 | SendAlertToUser(agentID, message, false); |
82 | } | 102 | } |
83 | 103 | ||
84 | public void SendAlertToUser(UUID agentID, string message, bool modal) | 104 | public void SendAlertToUser(UUID agentID, string message, bool modal) |
85 | { | 105 | { |
86 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 106 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
87 | 107 | ||
88 | if (sp != null) | 108 | if (sp != null) |
89 | sp.ControllingClient.SendAgentAlertMessage(message, modal); | 109 | sp.ControllingClient.SendAgentAlertMessage(message, modal); |
90 | } | 110 | } |
91 | 111 | ||
92 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) | 112 | public void SendAlertToUser(string firstName, string lastName, |
113 | string message, bool modal) | ||
93 | { | 114 | { |
94 | ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); | 115 | ScenePresence presence = m_scene.GetScenePresence(firstName, |
116 | lastName); | ||
95 | if (presence != null) | 117 | if (presence != null) |
96 | presence.ControllingClient.SendAgentAlertMessage(message, modal); | 118 | { |
119 | presence.ControllingClient.SendAgentAlertMessage(message, | ||
120 | modal); | ||
121 | } | ||
97 | } | 122 | } |
98 | 123 | ||
99 | public void SendGeneralAlert(string message) | 124 | public void SendGeneralAlert(string message) |
100 | { | 125 | { |
101 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 126 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
@@ -104,11 +129,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
104 | }); | 129 | }); |
105 | } | 130 | } |
106 | 131 | ||
107 | public void SendDialogToUser( | 132 | public void SendDialogToUser(UUID avatarID, string objectName, |
108 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, | 133 | UUID objectID, UUID ownerID, string message, UUID textureID, |
109 | string message, UUID textureID, int ch, string[] buttonlabels) | 134 | int ch, string[] buttonlabels) |
110 | { | 135 | { |
111 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); | 136 | UserAccount account = m_scene.UserAccountService.GetUserAccount( |
137 | m_scene.RegionInfo.ScopeID, ownerID); | ||
112 | string ownerFirstName, ownerLastName; | 138 | string ownerFirstName, ownerLastName; |
113 | if (account != null) | 139 | if (account != null) |
114 | { | 140 | { |
@@ -123,29 +149,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
123 | 149 | ||
124 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 150 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
125 | if (sp != null) | 151 | if (sp != null) |
126 | sp.ControllingClient.SendDialog( | 152 | { |
127 | objectName, objectID, ownerID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); | 153 | sp.ControllingClient.SendDialog(objectName, objectID, ownerID, |
154 | ownerFirstName, ownerLastName, message, textureID, ch, | ||
155 | buttonlabels); | ||
156 | } | ||
128 | } | 157 | } |
129 | 158 | ||
130 | public void SendUrlToUser( | 159 | public void SendUrlToUser(UUID avatarID, string objectName, |
131 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) | 160 | UUID objectID, UUID ownerID, bool groupOwned, string message, |
161 | string url) | ||
132 | { | 162 | { |
133 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 163 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
134 | 164 | ||
135 | if (sp != null) | 165 | if (sp != null) |
136 | sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); | 166 | { |
167 | sp.ControllingClient.SendLoadURL(objectName, objectID, | ||
168 | ownerID, groupOwned, message, url); | ||
169 | } | ||
137 | } | 170 | } |
138 | 171 | ||
139 | public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) | 172 | public void SendTextBoxToUser(UUID avatarid, string message, |
173 | int chatChannel, string name, UUID objectid, UUID ownerid) | ||
140 | { | 174 | { |
141 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); | 175 | UserAccount account = m_scene.UserAccountService.GetUserAccount( |
176 | m_scene.RegionInfo.ScopeID, ownerid); | ||
142 | string ownerFirstName, ownerLastName; | 177 | string ownerFirstName, ownerLastName; |
143 | UUID ownerID = UUID.Zero; | 178 | UUID ownerID = UUID.Zero; |
144 | if (account != null) | 179 | if (account != null) |
145 | { | 180 | { |
146 | ownerFirstName = account.FirstName; | 181 | ownerFirstName = account.FirstName; |
147 | ownerLastName = account.LastName; | 182 | ownerLastName = account.LastName; |
148 | ownerID = account.PrincipalID; | 183 | ownerID = account.PrincipalID; |
149 | } | 184 | } |
150 | else | 185 | else |
151 | { | 186 | { |
@@ -154,29 +189,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
154 | } | 189 | } |
155 | 190 | ||
156 | ScenePresence sp = m_scene.GetScenePresence(avatarid); | 191 | ScenePresence sp = m_scene.GetScenePresence(avatarid); |
157 | 192 | ||
158 | if (sp != null) | 193 | if (sp != null) |
159 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerID, ownerFirstName, ownerLastName, objectid); | 194 | { |
195 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, | ||
196 | name, ownerID, ownerFirstName, ownerLastName, | ||
197 | objectid); | ||
198 | } | ||
160 | } | 199 | } |
161 | 200 | ||
162 | public void SendNotificationToUsersInRegion( | 201 | public void SendNotificationToUsersInRegion(UUID fromAvatarID, |
163 | UUID fromAvatarID, string fromAvatarName, string message) | 202 | string fromAvatarName, string message) |
164 | { | 203 | { |
165 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 204 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
166 | { | 205 | { |
167 | client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); | 206 | client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, |
207 | message); | ||
168 | }); | 208 | }); |
169 | } | 209 | } |
170 | 210 | ||
171 | /// <summary> | 211 | /// <summary> |
172 | /// Handle an alert command from the console. | 212 | /// Handle an alert command from the console. |
173 | /// </summary> | 213 | /// </summary> |
174 | /// <param name="module"></param> | 214 | /// <param name="module"></param> |
175 | /// <param name="cmdparams"></param> | 215 | /// <param name="cmdparams"></param> |
176 | public void HandleAlertConsoleCommand(string module, string[] cmdparams) | 216 | public void HandleAlertConsoleCommand(string module, |
217 | string[] cmdparams) | ||
177 | { | 218 | { |
178 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) | 219 | if (m_scene.ConsoleScene() != null && |
220 | m_scene.ConsoleScene() != m_scene) | ||
221 | { | ||
179 | return; | 222 | return; |
223 | } | ||
180 | 224 | ||
181 | string message = string.Empty; | 225 | string message = string.Empty; |
182 | 226 | ||
@@ -184,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
184 | { | 228 | { |
185 | message = CombineParams(cmdparams, 1); | 229 | message = CombineParams(cmdparams, 1); |
186 | m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", | 230 | m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", |
187 | m_scene.RegionInfo.RegionName, message); | 231 | m_scene.RegionInfo.RegionName, message); |
188 | SendGeneralAlert(message); | 232 | SendGeneralAlert(message); |
189 | } | 233 | } |
190 | else if (cmdparams.Length > 3) | 234 | else if (cmdparams.Length > 3) |
@@ -192,9 +236,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
192 | string firstName = cmdparams[1]; | 236 | string firstName = cmdparams[1]; |
193 | string lastName = cmdparams[2]; | 237 | string lastName = cmdparams[2]; |
194 | message = CombineParams(cmdparams, 3); | 238 | message = CombineParams(cmdparams, 3); |
195 | m_log.InfoFormat( | 239 | m_log.InfoFormat("[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", |
196 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | 240 | m_scene.RegionInfo.RegionName, firstName, lastName, |
197 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | 241 | message); |
198 | SendAlertToUser(firstName, lastName, message, false); | 242 | SendAlertToUser(firstName, lastName, message, false); |
199 | } | 243 | } |
200 | else | 244 | else |
@@ -212,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
212 | { | 256 | { |
213 | result += commandParams[i] + " "; | 257 | result += commandParams[i] + " "; |
214 | } | 258 | } |
215 | 259 | ||
216 | return result; | 260 | return result; |
217 | } | 261 | } |
218 | } | 262 | } |