diff options
author | Dr Scofield | 2009-04-21 16:06:16 +0000 |
---|---|---|
committer | Dr Scofield | 2009-04-21 16:06:16 +0000 |
commit | 4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca (patch) | |
tree | 5542aade150e0d9da1032864b72a93db52b4bf4f /OpenSim/Region | |
parent | Thank you kindly, MPallari for a patch that: (diff) | |
download | opensim-SC_OLD-4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca.zip opensim-SC_OLD-4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca.tar.gz opensim-SC_OLD-4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca.tar.bz2 opensim-SC_OLD-4a8313f14c0aeffc87d37bd1f6c633a61c0a0fca.tar.xz |
culling AsteriskVoiceModule and SIPVoiceModule, now that we have
working FreeSwitchVoiceModule and soon will have a fully working
VivoxVoiceModule.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs | 292 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs | 234 |
2 files changed, 0 insertions, 526 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs deleted file mode 100644 index c827214..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs +++ /dev/null | |||
@@ -1,292 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using OpenMetaverse; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Framework.Communications.Capabilities; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using Caps=OpenSim.Framework.Communications.Capabilities.Caps; | ||
42 | |||
43 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.AsterixVoice | ||
44 | { | ||
45 | public class AsteriskVoiceModule : IRegionModule | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; | ||
51 | private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; | ||
52 | |||
53 | private string m_asterisk; | ||
54 | private string m_asterisk_password; | ||
55 | private string m_asterisk_salt; | ||
56 | private int m_asterisk_timeout; | ||
57 | private string m_confDomain; | ||
58 | private IConfig m_config; | ||
59 | private Scene m_scene; | ||
60 | private string m_sipDomain; | ||
61 | |||
62 | #region IRegionModule Members | ||
63 | |||
64 | public void Initialise(Scene scene, IConfigSource config) | ||
65 | { | ||
66 | m_scene = scene; | ||
67 | m_config = config.Configs["AsteriskVoice"]; | ||
68 | |||
69 | if (null == m_config) | ||
70 | { | ||
71 | m_log.Info("[ASTERISKVOICE] no config found, plugin disabled"); | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | if (!m_config.GetBoolean("enabled", false)) | ||
76 | { | ||
77 | m_log.Info("[ASTERISKVOICE] plugin disabled by configuration"); | ||
78 | return; | ||
79 | } | ||
80 | m_log.Info("[ASTERISKVOICE] plugin enabled"); | ||
81 | |||
82 | try | ||
83 | { | ||
84 | m_sipDomain = m_config.GetString("sip_domain", String.Empty); | ||
85 | m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain); | ||
86 | |||
87 | m_confDomain = m_config.GetString("conf_domain", String.Empty); | ||
88 | m_log.InfoFormat("[ASTERISKVOICE] using conf domain {0}", m_confDomain); | ||
89 | |||
90 | m_asterisk = m_config.GetString("asterisk_frontend", String.Empty); | ||
91 | m_asterisk_password = m_config.GetString("asterisk_password", String.Empty); | ||
92 | m_asterisk_timeout = m_config.GetInt("asterisk_timeout", 3000); | ||
93 | m_asterisk_salt = m_config.GetString("asterisk_salt", "Wuffwuff"); | ||
94 | if (String.IsNullOrEmpty(m_asterisk)) throw new Exception("missing asterisk_frontend config parameter"); | ||
95 | if (String.IsNullOrEmpty(m_asterisk_password)) throw new Exception("missing asterisk_password config parameter"); | ||
96 | m_log.InfoFormat("[ASTERISKVOICE] using asterisk front end {0}", m_asterisk); | ||
97 | |||
98 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
99 | } | ||
100 | catch (Exception e) | ||
101 | { | ||
102 | m_log.ErrorFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.Message); | ||
103 | m_log.DebugFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.ToString()); | ||
104 | return; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public void PostInitialise() | ||
109 | { | ||
110 | } | ||
111 | |||
112 | public void Close() | ||
113 | { | ||
114 | } | ||
115 | |||
116 | public string Name | ||
117 | { | ||
118 | get { return "AsteriskVoiceModule"; } | ||
119 | } | ||
120 | |||
121 | public bool IsSharedModule | ||
122 | { | ||
123 | get { return false; } | ||
124 | } | ||
125 | |||
126 | #endregion | ||
127 | |||
128 | public void OnRegisterCaps(UUID agentID, Caps caps) | ||
129 | { | ||
130 | m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
131 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
132 | caps.RegisterHandler("ParcelVoiceInfoRequest", | ||
133 | new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, | ||
134 | delegate(string request, string path, string param, | ||
135 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
136 | { | ||
137 | return ParcelVoiceInfoRequest(request, path, param, | ||
138 | agentID, caps); | ||
139 | })); | ||
140 | caps.RegisterHandler("ProvisionVoiceAccountRequest", | ||
141 | new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, | ||
142 | delegate(string request, string path, string param, | ||
143 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
144 | { | ||
145 | return ProvisionVoiceAccountRequest(request, path, param, | ||
146 | agentID, caps); | ||
147 | })); | ||
148 | } | ||
149 | |||
150 | /// <summary> | ||
151 | /// Callback for a client request for ParcelVoiceInfo | ||
152 | /// </summary> | ||
153 | /// <param name="request"></param> | ||
154 | /// <param name="path"></param> | ||
155 | /// <param name="param"></param> | ||
156 | /// <param name="agentID"></param> | ||
157 | /// <param name="caps"></param> | ||
158 | /// <returns></returns> | ||
159 | public string ParcelVoiceInfoRequest(string request, string path, string param, | ||
160 | UUID agentID, Caps caps) | ||
161 | { | ||
162 | // we need to do: | ||
163 | // - send channel_uri: as "sip:regionID@m_sipDomain" | ||
164 | try | ||
165 | { | ||
166 | m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", | ||
167 | request, path, param); | ||
168 | |||
169 | |||
170 | // setup response to client | ||
171 | Hashtable creds = new Hashtable(); | ||
172 | creds["channel_uri"] = String.Format("sip:{0}@{1}", | ||
173 | m_scene.RegionInfo.RegionID, m_sipDomain); | ||
174 | |||
175 | string regionName = m_scene.RegionInfo.RegionName; | ||
176 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
177 | if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); | ||
178 | LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
179 | |||
180 | LLSDParcelVoiceInfoResponse parcelVoiceInfo = | ||
181 | new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); | ||
182 | |||
183 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | ||
184 | |||
185 | |||
186 | // update region on asterisk-opensim frontend | ||
187 | Hashtable requestData = new Hashtable(); | ||
188 | requestData["admin_password"] = m_asterisk_password; | ||
189 | requestData["region"] = m_scene.RegionInfo.RegionID.ToString(); | ||
190 | if (!String.IsNullOrEmpty(m_confDomain)) | ||
191 | { | ||
192 | requestData["region"] += String.Format("@{0}", m_confDomain); | ||
193 | } | ||
194 | |||
195 | ArrayList SendParams = new ArrayList(); | ||
196 | SendParams.Add(requestData); | ||
197 | XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams); | ||
198 | XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); | ||
199 | Hashtable responseData = (Hashtable) updateAccountResponse.Value; | ||
200 | |||
201 | if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed"); | ||
202 | |||
203 | bool success = Convert.ToBoolean((string) responseData["success"]); | ||
204 | if (!success) throw new Exception("region_update failed"); | ||
205 | |||
206 | |||
207 | m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: {0}", r); | ||
208 | return r; | ||
209 | } | ||
210 | catch (Exception e) | ||
211 | { | ||
212 | m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0}, retry later", e.Message); | ||
213 | m_log.DebugFormat("[ASTERISKVOICE][CAPS][PARCELVOICE]: {0} failed", e.ToString()); | ||
214 | |||
215 | return "<llsd>undef</llsd>"; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// Callback for a client request for Voice Account Details | ||
221 | /// </summary> | ||
222 | /// <param name="request"></param> | ||
223 | /// <param name="path"></param> | ||
224 | /// <param name="param"></param> | ||
225 | /// <param name="agentID"></param> | ||
226 | /// <param name="caps"></param> | ||
227 | /// <returns></returns> | ||
228 | public string ProvisionVoiceAccountRequest(string request, string path, string param, | ||
229 | UUID agentID, Caps caps) | ||
230 | { | ||
231 | // we need to | ||
232 | // - get user data from UserProfileCacheService | ||
233 | // - generate nonce for user voice account password | ||
234 | // - issue XmlRpc request to asterisk opensim front end: | ||
235 | // + user: base 64 encoded user name (otherwise SL | ||
236 | // client is unhappy) | ||
237 | // + password: nonce | ||
238 | // - the XmlRpc call to asteris-opensim was successful: | ||
239 | // send account details back to client | ||
240 | try | ||
241 | { | ||
242 | m_log.DebugFormat("[ASTERISKVOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", | ||
243 | request, path, param); | ||
244 | |||
245 | // get user data & prepare voice account response | ||
246 | string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); | ||
247 | voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); | ||
248 | |||
249 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
250 | if (null == userInfo) throw new Exception("cannot get user details"); | ||
251 | |||
252 | // we generate a nonce everytime | ||
253 | string voicePassword = "$1$" + Util.Md5Hash(DateTime.UtcNow.ToLongTimeString() + m_asterisk_salt); | ||
254 | LLSDVoiceAccountResponse voiceAccountResponse = | ||
255 | new LLSDVoiceAccountResponse(voiceUser, voicePassword); | ||
256 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | ||
257 | m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); | ||
258 | |||
259 | |||
260 | // update user account on asterisk frontend | ||
261 | Hashtable requestData = new Hashtable(); | ||
262 | requestData["admin_password"] = m_asterisk_password; | ||
263 | requestData["username"] = voiceUser; | ||
264 | if (!String.IsNullOrEmpty(m_sipDomain)) | ||
265 | { | ||
266 | requestData["username"] += String.Format("@{0}", m_sipDomain); | ||
267 | } | ||
268 | requestData["password"] = voicePassword; | ||
269 | |||
270 | ArrayList SendParams = new ArrayList(); | ||
271 | SendParams.Add(requestData); | ||
272 | XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams); | ||
273 | XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); | ||
274 | Hashtable responseData = (Hashtable) updateAccountResponse.Value; | ||
275 | |||
276 | if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed"); | ||
277 | |||
278 | bool success = Convert.ToBoolean((string) responseData["success"]); | ||
279 | if (!success) throw new Exception("account_update failed"); | ||
280 | |||
281 | return r; | ||
282 | } | ||
283 | catch (Exception e) | ||
284 | { | ||
285 | m_log.ErrorFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); | ||
286 | m_log.DebugFormat("[ASTERISKVOICE][CAPS][PROVISIONVOICE]: {0} failed", e.ToString()); | ||
287 | |||
288 | return "<llsd>undef</llsd>"; | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs deleted file mode 100644 index d00a256..0000000 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs +++ /dev/null | |||
@@ -1,234 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using OpenMetaverse; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Capabilities; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using Caps=OpenSim.Framework.Communications.Capabilities.Caps; | ||
41 | |||
42 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice | ||
43 | { | ||
44 | public class SIPVoiceModule : IRegionModule | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; | ||
50 | private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; | ||
51 | private static readonly string m_chatSessionRequestPath = "0009/"; | ||
52 | private IConfig m_config; | ||
53 | private Scene m_scene; | ||
54 | private string m_sipDomain; | ||
55 | |||
56 | #region IRegionModule Members | ||
57 | |||
58 | public void Initialise(Scene scene, IConfigSource config) | ||
59 | { | ||
60 | m_scene = scene; | ||
61 | m_config = config.Configs["Voice"]; | ||
62 | |||
63 | if (null == m_config || !m_config.GetBoolean("enabled", false)) | ||
64 | { | ||
65 | m_log.Info("[VOICE] plugin disabled"); | ||
66 | return; | ||
67 | } | ||
68 | m_log.Info("[VOICE] plugin enabled"); | ||
69 | |||
70 | m_sipDomain = m_config.GetString("sip_domain", String.Empty); | ||
71 | if (String.IsNullOrEmpty(m_sipDomain)) | ||
72 | { | ||
73 | m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); | ||
74 | m_log.Info("[VOICE] plugin disabled"); | ||
75 | return; | ||
76 | } | ||
77 | m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); | ||
78 | |||
79 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public void Close() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | public string Name | ||
91 | { | ||
92 | get { return "VoiceModule"; } | ||
93 | } | ||
94 | |||
95 | public bool IsSharedModule | ||
96 | { | ||
97 | get { return false; } | ||
98 | } | ||
99 | |||
100 | #endregion | ||
101 | |||
102 | public void OnRegisterCaps(UUID agentID, Caps caps) | ||
103 | { | ||
104 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
105 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
106 | caps.RegisterHandler("ParcelVoiceInfoRequest", | ||
107 | new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, | ||
108 | delegate(string request, string path, string param, | ||
109 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
110 | { | ||
111 | return ParcelVoiceInfoRequest(request, path, param, | ||
112 | agentID, caps); | ||
113 | })); | ||
114 | caps.RegisterHandler("ProvisionVoiceAccountRequest", | ||
115 | new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, | ||
116 | delegate(string request, string path, string param, | ||
117 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
118 | { | ||
119 | return ProvisionVoiceAccountRequest(request, path, param, | ||
120 | agentID, caps); | ||
121 | })); | ||
122 | caps.RegisterHandler("ChatSessionRequest", | ||
123 | new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, | ||
124 | delegate(string request, string path, string param, | ||
125 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
126 | { | ||
127 | return ChatSessionRequest(request, path, param, | ||
128 | agentID, caps); | ||
129 | })); | ||
130 | |||
131 | } | ||
132 | |||
133 | /// <summary> | ||
134 | /// Callback for a client request for ParcelVoiceInfo | ||
135 | /// </summary> | ||
136 | /// <param name="request"></param> | ||
137 | /// <param name="path"></param> | ||
138 | /// <param name="param"></param> | ||
139 | /// <param name="agentID"></param> | ||
140 | /// <param name="caps"></param> | ||
141 | /// <returns></returns> | ||
142 | public string ParcelVoiceInfoRequest(string request, string path, string param, | ||
143 | UUID agentID, Caps caps) | ||
144 | { | ||
145 | try | ||
146 | { | ||
147 | m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
148 | |||
149 | // FIXME: get the creds from region file or from config | ||
150 | Hashtable creds = new Hashtable(); | ||
151 | |||
152 | creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); | ||
153 | |||
154 | string regionName = m_scene.RegionInfo.RegionName; | ||
155 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
156 | if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); | ||
157 | LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
158 | |||
159 | LLSDParcelVoiceInfoResponse parcelVoiceInfo = | ||
160 | new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); | ||
161 | |||
162 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | ||
163 | m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); | ||
164 | |||
165 | return r; | ||
166 | } | ||
167 | catch (Exception e) | ||
168 | { | ||
169 | m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); | ||
170 | } | ||
171 | |||
172 | return null; | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Callback for a client request for Voice Account Details | ||
177 | /// </summary> | ||
178 | /// <param name="request"></param> | ||
179 | /// <param name="path"></param> | ||
180 | /// <param name="param"></param> | ||
181 | /// <param name="agentID"></param> | ||
182 | /// <param name="caps"></param> | ||
183 | /// <returns></returns> | ||
184 | public string ProvisionVoiceAccountRequest(string request, string path, string param, | ||
185 | UUID agentID, Caps caps) | ||
186 | { | ||
187 | try | ||
188 | { | ||
189 | m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", | ||
190 | request, path, param); | ||
191 | |||
192 | string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); | ||
193 | voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); | ||
194 | |||
195 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
196 | if (null == userInfo) throw new Exception("cannot get user details"); | ||
197 | |||
198 | LLSDVoiceAccountResponse voiceAccountResponse = | ||
199 | new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); | ||
200 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | ||
201 | m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); | ||
202 | return r; | ||
203 | } | ||
204 | catch (Exception e) | ||
205 | { | ||
206 | m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); | ||
207 | } | ||
208 | |||
209 | return null; | ||
210 | } | ||
211 | |||
212 | /// <summary> | ||
213 | /// Callback for a client request for ParcelVoiceInfo | ||
214 | /// </summary> | ||
215 | /// <param name="scene">current scene object of the client</param> | ||
216 | /// <param name="request"></param> | ||
217 | /// <param name="path"></param> | ||
218 | /// <param name="param"></param> | ||
219 | /// <param name="agentID"></param> | ||
220 | /// <param name="caps"></param> | ||
221 | /// <returns></returns> | ||
222 | public string ChatSessionRequest(string request, string path, string param, | ||
223 | UUID agentID, Caps caps) | ||
224 | { | ||
225 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
226 | string avatarName = avatar.Name; | ||
227 | |||
228 | m_log.DebugFormat("[CAPS][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", | ||
229 | avatarName, request, path, param); | ||
230 | return "<llsd>true</llsd>"; | ||
231 | } | ||
232 | |||
233 | } | ||
234 | } | ||