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