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