diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
9 files changed, 467 insertions, 116 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs index 5a37fad..b5d9fda 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs | |||
@@ -461,7 +461,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
461 | 461 | ||
462 | string result = instr; | 462 | string result = instr; |
463 | 463 | ||
464 | if (result == null || result.Length == 0) | 464 | if (string.IsNullOrEmpty(result)) |
465 | return result; | 465 | return result; |
466 | 466 | ||
467 | // Repeatedly scan the string until all possible | 467 | // Repeatedly scan the string until all possible |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index 018357a..c48e585 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | |||
@@ -375,11 +375,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
375 | scene.GetRootAgentCount(), scene.RegionInfo.RegionName, | 375 | scene.GetRootAgentCount(), scene.RegionInfo.RegionName, |
376 | scene.RegionInfo.RegionID, | 376 | scene.RegionInfo.RegionID, |
377 | DateTime.UtcNow.ToString("s"))); | 377 | DateTime.UtcNow.ToString("s"))); |
378 | |||
378 | scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 379 | scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
379 | { | 380 | { |
380 | list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); | 381 | list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); |
381 | list.Append("</avatars>"); | ||
382 | }); | 382 | }); |
383 | |||
384 | list.Append("</avatars>"); | ||
383 | string payload = list.ToString(); | 385 | string payload = list.ToString(); |
384 | 386 | ||
385 | // post via REST to broker | 387 | // post via REST to broker |
diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs new file mode 100644 index 0000000..5a6b284 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs | |||
@@ -0,0 +1,220 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Mono.Addins; | ||
36 | using NDesk.Options; | ||
37 | using Nini.Config; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Console; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | |||
44 | namespace OpenSim.Region.OptionalModules.Avatar.SitStand | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// A module that just holds commands for changing avatar sitting and standing states. | ||
48 | /// </summary> | ||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AnimationsCommandModule")] | ||
50 | public class SitStandCommandModule : INonSharedRegionModule | ||
51 | { | ||
52 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private Scene m_scene; | ||
55 | |||
56 | public string Name { get { return "SitStand Command Module"; } } | ||
57 | |||
58 | public Type ReplaceableInterface { get { return null; } } | ||
59 | |||
60 | public void Initialise(IConfigSource source) | ||
61 | { | ||
62 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE"); | ||
63 | } | ||
64 | |||
65 | public void PostInitialise() | ||
66 | { | ||
67 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE"); | ||
68 | } | ||
69 | |||
70 | public void Close() | ||
71 | { | ||
72 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE"); | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) | ||
76 | { | ||
77 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
78 | } | ||
79 | |||
80 | public void RemoveRegion(Scene scene) | ||
81 | { | ||
82 | // m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
83 | } | ||
84 | |||
85 | public void RegionLoaded(Scene scene) | ||
86 | { | ||
87 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
88 | |||
89 | m_scene = scene; | ||
90 | |||
91 | scene.AddCommand( | ||
92 | "Users", this, "sit user name", | ||
93 | "sit user name [--regex] <first-name> <last-name>", | ||
94 | "Sit the named user on an unoccupied object with a sit target.", | ||
95 | "If there are no such objects then nothing happens.\n" | ||
96 | + "If --regex is specified then the names are treated as regular expressions.", | ||
97 | HandleSitUserNameCommand); | ||
98 | |||
99 | scene.AddCommand( | ||
100 | "Users", this, "stand user name", | ||
101 | "stand user name [--regex] <first-name> <last-name>", | ||
102 | "Stand the named user.", | ||
103 | "If --regex is specified then the names are treated as regular expressions.", | ||
104 | HandleStandUserNameCommand); | ||
105 | } | ||
106 | |||
107 | private void HandleSitUserNameCommand(string module, string[] cmd) | ||
108 | { | ||
109 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
110 | return; | ||
111 | |||
112 | if (cmd.Length < 5) | ||
113 | { | ||
114 | MainConsole.Instance.Output("Usage: sit user name [--regex] <first-name> <last-name>"); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | List<ScenePresence> scenePresences = GetScenePresences(cmd); | ||
119 | |||
120 | foreach (ScenePresence sp in scenePresences) | ||
121 | { | ||
122 | if (sp.SitGround || sp.IsSatOnObject) | ||
123 | continue; | ||
124 | |||
125 | SceneObjectPart sitPart = null; | ||
126 | List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups(); | ||
127 | |||
128 | foreach (SceneObjectGroup sceneObject in sceneObjects) | ||
129 | { | ||
130 | if (sceneObject.IsAttachment) | ||
131 | continue; | ||
132 | |||
133 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
134 | { | ||
135 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) | ||
136 | { | ||
137 | sitPart = part; | ||
138 | break; | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | |||
143 | if (sitPart != null) | ||
144 | { | ||
145 | MainConsole.Instance.OutputFormat( | ||
146 | "Sitting {0} on {1} {2} in {3}", | ||
147 | sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); | ||
148 | |||
149 | sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); | ||
150 | sp.HandleAgentSit(sp.ControllingClient, sp.UUID); | ||
151 | } | ||
152 | else | ||
153 | { | ||
154 | MainConsole.Instance.OutputFormat( | ||
155 | "Could not find any unoccupied set seat on which to sit {0} in {1}. Aborting", | ||
156 | sp.Name, m_scene.Name); | ||
157 | |||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | private void HandleStandUserNameCommand(string module, string[] cmd) | ||
164 | { | ||
165 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
166 | return; | ||
167 | |||
168 | if (cmd.Length < 5) | ||
169 | { | ||
170 | MainConsole.Instance.Output("Usage: stand user name [--regex] <first-name> <last-name>"); | ||
171 | return; | ||
172 | } | ||
173 | |||
174 | List<ScenePresence> scenePresences = GetScenePresences(cmd); | ||
175 | |||
176 | foreach (ScenePresence sp in scenePresences) | ||
177 | { | ||
178 | if (sp.SitGround || sp.IsSatOnObject) | ||
179 | { | ||
180 | MainConsole.Instance.OutputFormat("Standing {0} in {1}", sp.Name, m_scene.Name); | ||
181 | sp.StandUp(); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | |||
186 | private List<ScenePresence> GetScenePresences(string[] cmdParams) | ||
187 | { | ||
188 | bool useRegex = false; | ||
189 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); | ||
190 | |||
191 | List<string> mainParams = options.Parse(cmdParams); | ||
192 | |||
193 | string firstName = mainParams[3]; | ||
194 | string lastName = mainParams[4]; | ||
195 | |||
196 | List<ScenePresence> scenePresencesMatched = new List<ScenePresence>(); | ||
197 | |||
198 | if (useRegex) | ||
199 | { | ||
200 | Regex nameRegex = new Regex(string.Format("{0} {1}", firstName, lastName)); | ||
201 | List<ScenePresence> scenePresences = m_scene.GetScenePresences(); | ||
202 | |||
203 | foreach (ScenePresence sp in scenePresences) | ||
204 | { | ||
205 | if (!sp.IsChildAgent && nameRegex.IsMatch(sp.Name)) | ||
206 | scenePresencesMatched.Add(sp); | ||
207 | } | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); | ||
212 | |||
213 | if (sp != null && !sp.IsChildAgent) | ||
214 | scenePresencesMatched.Add(sp); | ||
215 | } | ||
216 | |||
217 | return scenePresencesMatched; | ||
218 | } | ||
219 | } | ||
220 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 0cec959..2b33084 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | |||
@@ -326,15 +326,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
326 | "ParcelVoiceInfoRequest", | 326 | "ParcelVoiceInfoRequest", |
327 | agentID.ToString())); | 327 | agentID.ToString())); |
328 | 328 | ||
329 | caps.RegisterHandler( | 329 | //caps.RegisterHandler( |
330 | "ChatSessionRequest", | 330 | // "ChatSessionRequest", |
331 | new RestStreamHandler( | 331 | // new RestStreamHandler( |
332 | "POST", | 332 | // "POST", |
333 | capsBase + m_chatSessionRequestPath, | 333 | // capsBase + m_chatSessionRequestPath, |
334 | (request, path, param, httpRequest, httpResponse) | 334 | // (request, path, param, httpRequest, httpResponse) |
335 | => ChatSessionRequest(scene, request, path, param, agentID, caps), | 335 | // => ChatSessionRequest(scene, request, path, param, agentID, caps), |
336 | "ChatSessionRequest", | 336 | // "ChatSessionRequest", |
337 | agentID.ToString())); | 337 | // agentID.ToString())); |
338 | } | 338 | } |
339 | 339 | ||
340 | /// <summary> | 340 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 9e6cc1a..38ba54d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | |||
@@ -117,6 +117,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
117 | 117 | ||
118 | private IConfig m_config; | 118 | private IConfig m_config; |
119 | 119 | ||
120 | private object m_Lock; | ||
121 | |||
120 | public void Initialise(IConfigSource config) | 122 | public void Initialise(IConfigSource config) |
121 | { | 123 | { |
122 | 124 | ||
@@ -128,6 +130,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
128 | if (!m_config.GetBoolean("enabled", false)) | 130 | if (!m_config.GetBoolean("enabled", false)) |
129 | return; | 131 | return; |
130 | 132 | ||
133 | m_Lock = new object(); | ||
134 | |||
131 | try | 135 | try |
132 | { | 136 | { |
133 | // retrieve configuration variables | 137 | // retrieve configuration variables |
@@ -429,15 +433,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
429 | "ParcelVoiceInfoRequest", | 433 | "ParcelVoiceInfoRequest", |
430 | agentID.ToString())); | 434 | agentID.ToString())); |
431 | 435 | ||
432 | caps.RegisterHandler( | 436 | //caps.RegisterHandler( |
433 | "ChatSessionRequest", | 437 | // "ChatSessionRequest", |
434 | new RestStreamHandler( | 438 | // new RestStreamHandler( |
435 | "POST", | 439 | // "POST", |
436 | capsBase + m_chatSessionRequestPath, | 440 | // capsBase + m_chatSessionRequestPath, |
437 | (request, path, param, httpRequest, httpResponse) | 441 | // (request, path, param, httpRequest, httpResponse) |
438 | => ChatSessionRequest(scene, request, path, param, agentID, caps), | 442 | // => ChatSessionRequest(scene, request, path, param, agentID, caps), |
439 | "ChatSessionRequest", | 443 | // "ChatSessionRequest", |
440 | agentID.ToString())); | 444 | // agentID.ToString())); |
441 | } | 445 | } |
442 | 446 | ||
443 | /// <summary> | 447 | /// <summary> |
@@ -823,11 +827,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
823 | { | 827 | { |
824 | string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); | 828 | string requrl = String.Format(m_vivoxChannelPath, m_vivoxServer, "create", channelId, m_authToken); |
825 | 829 | ||
826 | if (parent != null && parent != String.Empty) | 830 | if (!string.IsNullOrEmpty(parent)) |
827 | { | 831 | { |
828 | requrl = String.Format("{0}&chan_parent={1}", requrl, parent); | 832 | requrl = String.Format("{0}&chan_parent={1}", requrl, parent); |
829 | } | 833 | } |
830 | if (description != null && description != String.Empty) | 834 | if (!string.IsNullOrEmpty(description)) |
831 | { | 835 | { |
832 | requrl = String.Format("{0}&chan_desc={1}", requrl, description); | 836 | requrl = String.Format("{0}&chan_desc={1}", requrl, description); |
833 | } | 837 | } |
@@ -837,7 +841,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
837 | requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); | 841 | requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); |
838 | requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); | 842 | requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); |
839 | requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); | 843 | requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); |
840 | requrl = String.Format("{0}&chan_ckamping_distance={1}", requrl, m_vivoxChannelClampingDistance); | 844 | requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance); |
841 | 845 | ||
842 | XmlElement resp = VivoxCall(requrl, true); | 846 | XmlElement resp = VivoxCall(requrl, true); |
843 | if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) | 847 | if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) |
@@ -863,7 +867,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
863 | // requrl = String.Format("{0}&chan_parent={1}", requrl, parent); | 867 | // requrl = String.Format("{0}&chan_parent={1}", requrl, parent); |
864 | // } | 868 | // } |
865 | 869 | ||
866 | if (description != null && description != String.Empty) | 870 | if (!string.IsNullOrEmpty(description)) |
867 | { | 871 | { |
868 | requrl = String.Format("{0}&chan_desc={1}", requrl, description); | 872 | requrl = String.Format("{0}&chan_desc={1}", requrl, description); |
869 | } | 873 | } |
@@ -1049,7 +1053,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
1049 | private XmlElement VivoxDeleteChannel(string parent, string channelid) | 1053 | private XmlElement VivoxDeleteChannel(string parent, string channelid) |
1050 | { | 1054 | { |
1051 | string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); | 1055 | string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); |
1052 | if (parent != null && parent != String.Empty) | 1056 | if (!string.IsNullOrEmpty(parent)) |
1053 | { | 1057 | { |
1054 | requrl = String.Format("{0}&chan_parent={1}", requrl, parent); | 1058 | requrl = String.Format("{0}&chan_parent={1}", requrl, parent); |
1055 | } | 1059 | } |
@@ -1118,25 +1122,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
1118 | 1122 | ||
1119 | doc = new XmlDocument(); | 1123 | doc = new XmlDocument(); |
1120 | 1124 | ||
1121 | try | 1125 | // Let's serialize all calls to Vivox. Most of these are driven by |
1126 | // the clients (CAPs), when the user arrives at the region. We don't | ||
1127 | // want to issue many simultaneous http requests to Vivox, because mono | ||
1128 | // doesn't like that | ||
1129 | lock (m_Lock) | ||
1122 | { | 1130 | { |
1123 | // Otherwise prepare the request | 1131 | try |
1124 | // m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); | 1132 | { |
1133 | // Otherwise prepare the request | ||
1134 | //m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); | ||
1125 | 1135 | ||
1126 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); | 1136 | HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); |
1127 | 1137 | ||
1128 | // We are sending just parameters, no content | 1138 | // We are sending just parameters, no content |
1129 | req.ContentLength = 0; | 1139 | req.ContentLength = 0; |
1130 | 1140 | ||
1131 | // Send request and retrieve the response | 1141 | // Send request and retrieve the response |
1132 | using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) | 1142 | using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) |
1133 | using (Stream s = rsp.GetResponseStream()) | 1143 | using (Stream s = rsp.GetResponseStream()) |
1134 | using (XmlTextReader rdr = new XmlTextReader(s)) | 1144 | using (XmlTextReader rdr = new XmlTextReader(s)) |
1135 | doc.Load(rdr); | 1145 | doc.Load(rdr); |
1136 | } | 1146 | } |
1137 | catch (Exception e) | 1147 | catch (Exception e) |
1138 | { | 1148 | { |
1139 | m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); | 1149 | m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); |
1150 | } | ||
1140 | } | 1151 | } |
1141 | 1152 | ||
1142 | // If we're debugging server responses, dump the whole | 1153 | // If we're debugging server responses, dump the whole |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index d0a5989..d2a6828 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework.Communications; | |||
39 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
42 | using System.Text; | ||
42 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; | 43 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; |
43 | 44 | ||
44 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 45 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
@@ -250,7 +251,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
250 | 251 | ||
251 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | 252 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; |
252 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | 253 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; |
253 | client.OnDirFindQuery += OnDirFindQuery; | ||
254 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; | 254 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; |
255 | 255 | ||
256 | // Used for Notices and Group Invites/Accept/Reject | 256 | // Used for Notices and Group Invites/Accept/Reject |
@@ -303,21 +303,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
303 | } | 303 | } |
304 | */ | 304 | */ |
305 | 305 | ||
306 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | ||
307 | { | ||
308 | if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) | ||
309 | { | ||
310 | if (m_debugEnabled) | ||
311 | m_log.DebugFormat( | ||
312 | "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", | ||
313 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | ||
314 | |||
315 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
316 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); | ||
317 | } | ||
318 | |||
319 | } | ||
320 | |||
321 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) | 306 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) |
322 | { | 307 | { |
323 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 308 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -437,44 +422,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
437 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); | 422 | string Subject = im.message.Substring(0, im.message.IndexOf('|')); |
438 | string Message = im.message.Substring(Subject.Length + 1); | 423 | string Message = im.message.Substring(Subject.Length + 1); |
439 | 424 | ||
425 | InventoryItemBase item = null; | ||
426 | bool hasAttachment = false; | ||
427 | UUID itemID = UUID.Zero; //Assignment to quiet compiler | ||
428 | UUID ownerID = UUID.Zero; //Assignment to quiet compiler | ||
440 | byte[] bucket; | 429 | byte[] bucket; |
441 | 430 | ||
442 | if ((im.binaryBucket.Length == 1) && (im.binaryBucket[0] == 0)) | 431 | if (im.binaryBucket.Length >= 1 && im.binaryBucket[0] > 0) |
443 | { | ||
444 | bucket = new byte[19]; | ||
445 | bucket[0] = 0; //dunno | ||
446 | bucket[1] = 0; //dunno | ||
447 | GroupID.ToBytes(bucket, 2); | ||
448 | bucket[18] = 0; //dunno | ||
449 | } | ||
450 | else | ||
451 | { | 432 | { |
452 | string binBucket = OpenMetaverse.Utils.BytesToString(im.binaryBucket); | 433 | string binBucket = OpenMetaverse.Utils.BytesToString(im.binaryBucket); |
453 | binBucket = binBucket.Remove(0, 14).Trim(); | 434 | binBucket = binBucket.Remove(0, 14).Trim(); |
454 | if (m_debugEnabled) | 435 | |
436 | OSDMap binBucketOSD = (OSDMap)OSDParser.DeserializeLLSDXml(binBucket); | ||
437 | if (binBucketOSD is OSD) | ||
455 | { | 438 | { |
456 | m_log.WarnFormat("I don't understand a group notice binary bucket of: {0}", binBucket); | 439 | OSDMap binBucketMap = (OSDMap)binBucketOSD; |
440 | |||
441 | itemID = binBucketMap["item_id"].AsUUID(); | ||
442 | ownerID = binBucketMap["owner_id"].AsUUID(); | ||
457 | 443 | ||
458 | OSDMap binBucketOSD = (OSDMap)OSDParser.DeserializeLLSDXml(binBucket); | 444 | //Attempt to get the details of the attached item. |
459 | 445 | //If sender doesn't own the attachment, the item | |
460 | foreach (string key in binBucketOSD.Keys) | 446 | //variable will be set to null and attachment will |
447 | //not be included with the group notice. | ||
448 | Scene scene = (Scene)remoteClient.Scene; | ||
449 | item = new InventoryItemBase(itemID, ownerID); | ||
450 | item = scene.InventoryService.GetItem(item); | ||
451 | |||
452 | if (item != null) | ||
461 | { | 453 | { |
462 | if (binBucketOSD.ContainsKey(key)) | 454 | //Got item details so include the attachment. |
463 | { | 455 | hasAttachment = true; |
464 | m_log.WarnFormat("{0}: {1}", key, binBucketOSD[key].ToString()); | ||
465 | } | ||
466 | } | 456 | } |
467 | } | 457 | } |
468 | 458 | else | |
469 | // treat as if no attachment | 459 | { |
460 | m_log.DebugFormat("[Groups]: Received OSD with unexpected type: {0}", binBucketOSD.GetType()); | ||
461 | } | ||
462 | } | ||
463 | |||
464 | if (hasAttachment) | ||
465 | { | ||
466 | //Bucket contains information about attachment. | ||
467 | // | ||
468 | //Byte offset and description of bucket data: | ||
469 | //0: 1 byte indicating if attachment is present | ||
470 | //1: 1 byte indicating the type of attachment | ||
471 | //2: 16 bytes - Group UUID | ||
472 | //18: 16 bytes - UUID of the attachment owner | ||
473 | //34: 16 bytes - UUID of the attachment | ||
474 | //50: variable - Name of the attachment | ||
475 | //??: NUL byte to terminate the attachment name | ||
476 | byte[] name = Encoding.UTF8.GetBytes(item.Name); | ||
477 | bucket = new byte[51 + name.Length];//3 bytes, 3 UUIDs, and name | ||
478 | bucket[0] = 1; //Has attachment flag | ||
479 | bucket[1] = (byte)item.InvType; //Type of Attachment | ||
480 | GroupID.ToBytes(bucket, 2); | ||
481 | ownerID.ToBytes(bucket, 18); | ||
482 | itemID.ToBytes(bucket, 34); | ||
483 | name.CopyTo(bucket, 50); | ||
484 | } | ||
485 | else | ||
486 | { | ||
470 | bucket = new byte[19]; | 487 | bucket = new byte[19]; |
471 | bucket[0] = 0; //dunno | 488 | bucket[0] = 0; //Has attachment flag |
472 | bucket[1] = 0; //dunno | 489 | bucket[1] = 0; //Type of attachment |
473 | GroupID.ToBytes(bucket, 2); | 490 | GroupID.ToBytes(bucket, 2); |
474 | bucket[18] = 0; //dunno | 491 | bucket[18] = 0; //NUL terminate name of attachment |
475 | } | 492 | } |
476 | 493 | ||
477 | |||
478 | m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); | 494 | m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); |
479 | if (OnNewGroupNotice != null) | 495 | if (OnNewGroupNotice != null) |
480 | { | 496 | { |
@@ -499,7 +515,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
499 | 515 | ||
500 | if (member.AcceptNotices) | 516 | if (member.AcceptNotices) |
501 | { | 517 | { |
502 | // Build notice IIM | 518 | // Build notice IM |
503 | GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); | 519 | GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); |
504 | 520 | ||
505 | msg.toAgentID = member.AgentID.Guid; | 521 | msg.toAgentID = member.AgentID.Guid; |
@@ -508,10 +524,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
508 | } | 524 | } |
509 | } | 525 | } |
510 | } | 526 | } |
511 | 527 | ||
528 | if (im.dialog == (byte)InstantMessageDialog.GroupNoticeInventoryAccepted) | ||
529 | { | ||
530 | //Is bucket large enough to hold UUID of the attachment? | ||
531 | if (im.binaryBucket.Length < 16) | ||
532 | return; | ||
533 | |||
534 | UUID noticeID = new UUID(im.imSessionID); | ||
535 | |||
536 | GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); | ||
537 | if (notice != null) | ||
538 | { | ||
539 | UUID giver = new UUID(notice.BinaryBucket, 18); | ||
540 | UUID attachmentUUID = new UUID(notice.BinaryBucket, 34); | ||
541 | |||
542 | if (m_debugEnabled) | ||
543 | m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId); | ||
544 | |||
545 | InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId, | ||
546 | giver, attachmentUUID); | ||
547 | |||
548 | if (itemCopy == null) | ||
549 | { | ||
550 | remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); | ||
551 | return; | ||
552 | } | ||
553 | |||
554 | remoteClient.SendInventoryItemCreateUpdate(itemCopy, 0); | ||
555 | } | ||
556 | } | ||
557 | |||
512 | // Interop, received special 210 code for ejecting a group member | 558 | // Interop, received special 210 code for ejecting a group member |
513 | // this only works within the comms servers domain, and won't work hypergrid | 559 | // this only works within the comms servers domain, and won't work hypergrid |
514 | // TODO:FIXME: Use a presense server of some kind to find out where the | 560 | // TODO:FIXME: Use a presence server of some kind to find out where the |
515 | // client actually is, and try contacting that region directly to notify them, | 561 | // client actually is, and try contacting that region directly to notify them, |
516 | // or provide the notification via xmlrpc update queue | 562 | // or provide the notification via xmlrpc update queue |
517 | if ((im.dialog == 210)) | 563 | if ((im.dialog == 210)) |
@@ -889,26 +935,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
889 | 935 | ||
890 | if (data != null) | 936 | if (data != null) |
891 | { | 937 | { |
892 | GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null); | 938 | GridInstantMessage msg = CreateGroupNoticeIM(remoteClient.AgentId, groupNoticeID, (byte)InstantMessageDialog.GroupNoticeRequested); |
893 | |||
894 | GridInstantMessage msg = new GridInstantMessage(); | ||
895 | msg.imSessionID = UUID.Zero.Guid; | ||
896 | msg.fromAgentID = data.GroupID.Guid; | ||
897 | msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; | ||
898 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
899 | msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; | ||
900 | msg.message = data.noticeData.Subject + "|" + data.Message; | ||
901 | msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNoticeRequested; | ||
902 | msg.fromGroup = true; | ||
903 | msg.offline = (byte)0; | ||
904 | msg.ParentEstateID = 0; | ||
905 | msg.Position = Vector3.Zero; | ||
906 | msg.RegionID = UUID.Zero.Guid; | ||
907 | msg.binaryBucket = data.BinaryBucket; | ||
908 | 939 | ||
909 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); | 940 | OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); |
910 | } | 941 | } |
911 | |||
912 | } | 942 | } |
913 | 943 | ||
914 | public GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog) | 944 | public GridInstantMessage CreateGroupNoticeIM(UUID agentID, UUID groupNoticeID, byte dialog) |
@@ -916,10 +946,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
916 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 946 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
917 | 947 | ||
918 | GridInstantMessage msg = new GridInstantMessage(); | 948 | GridInstantMessage msg = new GridInstantMessage(); |
919 | msg.imSessionID = UUID.Zero.Guid; | 949 | byte[] bucket; |
950 | |||
951 | msg.imSessionID = groupNoticeID.Guid; | ||
920 | msg.toAgentID = agentID.Guid; | 952 | msg.toAgentID = agentID.Guid; |
921 | msg.dialog = dialog; | 953 | msg.dialog = dialog; |
922 | // msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.GroupNotice; | ||
923 | msg.fromGroup = true; | 954 | msg.fromGroup = true; |
924 | msg.offline = (byte)1; // Allow this message to be stored for offline use | 955 | msg.offline = (byte)1; // Allow this message to be stored for offline use |
925 | msg.ParentEstateID = 0; | 956 | msg.ParentEstateID = 0; |
@@ -933,13 +964,38 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
933 | msg.timestamp = info.noticeData.Timestamp; | 964 | msg.timestamp = info.noticeData.Timestamp; |
934 | msg.fromAgentName = info.noticeData.FromName; | 965 | msg.fromAgentName = info.noticeData.FromName; |
935 | msg.message = info.noticeData.Subject + "|" + info.Message; | 966 | msg.message = info.noticeData.Subject + "|" + info.Message; |
936 | msg.binaryBucket = info.BinaryBucket; | 967 | |
968 | if (info.BinaryBucket[0] > 0) | ||
969 | { | ||
970 | //32 is due to not needing space for two of the UUIDs. | ||
971 | //(Don't need UUID of attachment or its owner in IM) | ||
972 | //50 offset gets us to start of attachment name. | ||
973 | //We are skipping the attachment flag, type, and | ||
974 | //the three UUID fields at the start of the bucket. | ||
975 | bucket = new byte[info.BinaryBucket.Length-32]; | ||
976 | bucket[0] = 1; //Has attachment | ||
977 | bucket[1] = info.BinaryBucket[1]; | ||
978 | Array.Copy(info.BinaryBucket, 50, | ||
979 | bucket, 18, info.BinaryBucket.Length-50); | ||
980 | } | ||
981 | else | ||
982 | { | ||
983 | bucket = new byte[19]; | ||
984 | bucket[0] = 0; //No attachment | ||
985 | bucket[1] = 0; //Attachment type | ||
986 | bucket[18] = 0; //NUL terminate name | ||
987 | } | ||
988 | |||
989 | info.GroupID.ToBytes(bucket, 2); | ||
990 | msg.binaryBucket = bucket; | ||
937 | } | 991 | } |
938 | else | 992 | else |
939 | { | 993 | { |
940 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Group Notice {0} not found, composing empty message.", groupNoticeID); | 994 | if (m_debugEnabled) |
995 | m_log.DebugFormat("[GROUPS]: Group Notice {0} not found, composing empty message.", groupNoticeID); | ||
996 | |||
941 | msg.fromAgentID = UUID.Zero.Guid; | 997 | msg.fromAgentID = UUID.Zero.Guid; |
942 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); ; | 998 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); |
943 | msg.fromAgentName = string.Empty; | 999 | msg.fromAgentName = string.Empty; |
944 | msg.message = string.Empty; | 1000 | msg.message = string.Empty; |
945 | msg.binaryBucket = new byte[0]; | 1001 | msg.binaryBucket = new byte[0]; |
@@ -1063,7 +1119,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1063 | // Message to ejector | 1119 | // Message to ejector |
1064 | // Interop, received special 210 code for ejecting a group member | 1120 | // Interop, received special 210 code for ejecting a group member |
1065 | // this only works within the comms servers domain, and won't work hypergrid | 1121 | // this only works within the comms servers domain, and won't work hypergrid |
1066 | // TODO:FIXME: Use a presense server of some kind to find out where the | 1122 | // TODO:FIXME: Use a presence server of some kind to find out where the |
1067 | // client actually is, and try contacting that region directly to notify them, | 1123 | // client actually is, and try contacting that region directly to notify them, |
1068 | // or provide the notification via xmlrpc update queue | 1124 | // or provide the notification via xmlrpc update queue |
1069 | 1125 | ||
@@ -1178,6 +1234,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1178 | } | 1234 | } |
1179 | } | 1235 | } |
1180 | 1236 | ||
1237 | public List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query) | ||
1238 | { | ||
1239 | return m_groupData.FindGroups(GetRequestingAgentID(remoteClient), query); | ||
1240 | } | ||
1241 | |||
1242 | |||
1181 | #endregion | 1243 | #endregion |
1182 | 1244 | ||
1183 | #region Client/Update Tools | 1245 | #region Client/Update Tools |
@@ -1222,7 +1284,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1222 | AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); | 1284 | AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID)); |
1223 | AgentData.Add(AgentDataMap); | 1285 | AgentData.Add(AgentDataMap); |
1224 | 1286 | ||
1225 | |||
1226 | OSDArray GroupData = new OSDArray(data.Length); | 1287 | OSDArray GroupData = new OSDArray(data.Length); |
1227 | OSDArray NewGroupData = new OSDArray(data.Length); | 1288 | OSDArray NewGroupData = new OSDArray(data.Length); |
1228 | 1289 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 7bae8f7..8095b28 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -212,8 +212,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
212 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); | 212 | m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name); |
213 | 213 | ||
214 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); | 214 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); |
215 | if ((m_groupsServerURI == null) || | 215 | if (string.IsNullOrEmpty(m_groupsServerURI)) |
216 | (m_groupsServerURI == string.Empty)) | ||
217 | { | 216 | { |
218 | m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); | 217 | m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); |
219 | m_connectorEnabled = false; | 218 | m_connectorEnabled = false; |
@@ -438,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
438 | return null; | 437 | return null; |
439 | } | 438 | } |
440 | } | 439 | } |
441 | else if ((groupName != null) && (groupName != string.Empty)) | 440 | else if (!string.IsNullOrEmpty(groupName)) |
442 | { | 441 | { |
443 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) | 442 | if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) |
444 | { | 443 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index c1bdacb..26d2597 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -26,13 +26,23 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Net; | ||
29 | using System.Reflection; | 31 | using System.Reflection; |
30 | using Nini.Config; | 32 | using Nini.Config; |
31 | using NUnit.Framework; | 33 | using NUnit.Framework; |
32 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenMetaverse.Messages.Linden; | ||
36 | using OpenMetaverse.Packets; | ||
37 | using OpenMetaverse.StructuredData; | ||
33 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Region.ClientStack.Linden; | ||
43 | using OpenSim.Region.CoreModules.Framework; | ||
35 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
45 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; | ||
36 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | 47 | using OpenSim.Tests.Common.Mock; |
38 | 48 | ||
@@ -44,11 +54,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
44 | [TestFixture] | 54 | [TestFixture] |
45 | public class GroupsModuleTests : OpenSimTestCase | 55 | public class GroupsModuleTests : OpenSimTestCase |
46 | { | 56 | { |
57 | [SetUp] | ||
58 | public override void SetUp() | ||
59 | { | ||
60 | base.SetUp(); | ||
61 | |||
62 | uint port = 9999; | ||
63 | uint sslPort = 9998; | ||
64 | |||
65 | // This is an unfortunate bit of clean up we have to do because MainServer manages things through static | ||
66 | // variables and the VM is not restarted between tests. | ||
67 | MainServer.RemoveHttpServer(port); | ||
68 | |||
69 | BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); | ||
70 | MainServer.AddHttpServer(server); | ||
71 | MainServer.Instance = server; | ||
72 | } | ||
73 | |||
47 | [Test] | 74 | [Test] |
48 | public void TestBasic() | 75 | public void TestSendAgentGroupDataUpdate() |
49 | { | 76 | { |
50 | TestHelpers.InMethod(); | 77 | TestHelpers.InMethod(); |
51 | // log4net.Config.XmlConfigurator.Configure(); | 78 | // TestHelpers.EnableLogging(); |
52 | 79 | ||
53 | TestScene scene = new SceneHelpers().SetupScene(); | 80 | TestScene scene = new SceneHelpers().SetupScene(); |
54 | IConfigSource configSource = new IniConfigSource(); | 81 | IConfigSource configSource = new IniConfigSource(); |
@@ -56,8 +83,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
56 | config.Set("Enabled", true); | 83 | config.Set("Enabled", true); |
57 | config.Set("Module", "GroupsModule"); | 84 | config.Set("Module", "GroupsModule"); |
58 | config.Set("DebugEnabled", true); | 85 | config.Set("DebugEnabled", true); |
86 | |||
87 | GroupsModule gm = new GroupsModule(); | ||
88 | EventQueueGetModule eqgm = new EventQueueGetModule(); | ||
89 | |||
90 | // We need a capabilities module active so that adding the scene presence creates an event queue in the | ||
91 | // EventQueueGetModule | ||
59 | SceneHelpers.SetupSceneModules( | 92 | SceneHelpers.SetupSceneModules( |
60 | scene, configSource, new object[] { new MockGroupsServicesConnector() }); | 93 | scene, configSource, gm, new MockGroupsServicesConnector(), new CapabilitiesModule(), eqgm); |
94 | |||
95 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseStem("1")); | ||
96 | |||
97 | gm.SendAgentGroupDataUpdate(sp.ControllingClient); | ||
98 | |||
99 | Hashtable eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID); | ||
100 | |||
101 | Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); | ||
102 | |||
103 | // Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); | ||
104 | |||
105 | OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]); | ||
106 | OSDArray eventsOsd = (OSDArray)rawOsd["events"]; | ||
107 | |||
108 | bool foundUpdate = false; | ||
109 | foreach (OSD osd in eventsOsd) | ||
110 | { | ||
111 | OSDMap eventOsd = (OSDMap)osd; | ||
112 | |||
113 | if (eventOsd["message"] == "AgentGroupDataUpdate") | ||
114 | foundUpdate = true; | ||
115 | } | ||
116 | |||
117 | Assert.That(foundUpdate, Is.True, "Did not find AgentGroupDataUpdate in response"); | ||
118 | |||
119 | // TODO: More checking of more actual event data. | ||
61 | } | 120 | } |
62 | } | 121 | } |
63 | } \ No newline at end of file | 122 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 71b24ac..e28d0c2 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -168,8 +168,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
168 | m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); | 168 | m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); |
169 | 169 | ||
170 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); | 170 | m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); |
171 | if ((m_groupsServerURI == null) || | 171 | if (string.IsNullOrEmpty(m_groupsServerURI)) |
172 | (m_groupsServerURI == string.Empty)) | ||
173 | { | 172 | { |
174 | m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); | 173 | m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); |
175 | m_connectorEnabled = false; | 174 | m_connectorEnabled = false; |
@@ -354,7 +353,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
354 | { | 353 | { |
355 | param["GroupID"] = GroupID.ToString(); | 354 | param["GroupID"] = GroupID.ToString(); |
356 | } | 355 | } |
357 | if ((GroupName != null) && (GroupName != string.Empty)) | 356 | if (!string.IsNullOrEmpty(GroupName)) |
358 | { | 357 | { |
359 | param["Name"] = GroupName.ToString(); | 358 | param["Name"] = GroupName.ToString(); |
360 | } | 359 | } |