aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs123
1 files changed, 54 insertions, 69 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index b04b076..35819a6 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -50,7 +50,6 @@ using OpenSim.Region.Framework.Scenes;
50using Caps = OpenSim.Framework.Capabilities.Caps; 50using Caps = OpenSim.Framework.Capabilities.Caps;
51using System.Text.RegularExpressions; 51using System.Text.RegularExpressions;
52 52
53
54namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice 53namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
55{ 54{
56 public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule 55 public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule
@@ -76,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
76 // SLVoice client will do a GET on this prefix 75 // SLVoice client will do a GET on this prefix
77 private static string m_freeSwitchAPIPrefix; 76 private static string m_freeSwitchAPIPrefix;
78 77
79 // We need to return some information to SLVoice 78 // We need to return some information to SLVoice
80 // figured those out via curl 79 // figured those out via curl
81 // http://vd1.vivox.com/api2/viv_get_prelogin.php 80 // http://vd1.vivox.com/api2/viv_get_prelogin.php
82 // 81 //
@@ -102,9 +101,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
102 101
103 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); 102 private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>();
104 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); 103 private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>();
105 104
106 private Scene m_scene; 105 private Scene m_scene;
107 106
108 107
109 private IConfig m_config; 108 private IConfig m_config;
110 109
@@ -136,9 +135,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
136 m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); 135 m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty);
137 m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); 136 m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty);
138 m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); 137 m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty);
139 138
140 // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) 139 // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server)
141 140
142 string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); 141 string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty);
143 int servicePort = m_config.GetInt("freeswitch_service_port", 80); 142 int servicePort = m_config.GetInt("freeswitch_service_port", 80);
144 IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); 143 IPAddress serviceIPAddress = IPAddress.Parse(serviceIP);
@@ -156,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
156 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); 155 // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120);
157 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); 156 m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty);
158 m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); 157 m_freeSwitchContext = m_config.GetString("freeswitch_context", "default");
159 158
160 if (String.IsNullOrEmpty(m_freeSwitchServerUser) || 159 if (String.IsNullOrEmpty(m_freeSwitchServerUser) ||
161 String.IsNullOrEmpty(m_freeSwitchServerPass) || 160 String.IsNullOrEmpty(m_freeSwitchServerPass) ||
162 String.IsNullOrEmpty(m_freeSwitchRealm) || 161 String.IsNullOrEmpty(m_freeSwitchRealm) ||
@@ -182,9 +181,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
182 { 181 {
183 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), 182 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix),
184 FreeSwitchSLVoiceGetPreloginHTTPHandler); 183 FreeSwitchSLVoiceGetPreloginHTTPHandler);
185 184
186 // RestStreamHandler h = new 185 // RestStreamHandler h = new
187 // RestStreamHandler("GET", 186 // RestStreamHandler("GET",
188 // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); 187 // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler);
189 // MainServer.Instance.AddStreamHandler(h); 188 // MainServer.Instance.AddStreamHandler(h);
190 189
@@ -202,13 +201,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
202 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), 201 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix),
203 FreeSwitchSLVoiceBuddyHTTPHandler); 202 FreeSwitchSLVoiceBuddyHTTPHandler);
204 } 203 }
205
206
207
208 204
209
210 m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); 205 m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm);
211 206
212 m_FreeSwitchDirectory = new FreeSwitchDirectory(); 207 m_FreeSwitchDirectory = new FreeSwitchDirectory();
213 m_FreeSwitchDialplan = new FreeSwitchDialplan(); 208 m_FreeSwitchDialplan = new FreeSwitchDialplan();
214 209
@@ -225,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
225 } 220 }
226 } 221 }
227 222
228 if (m_pluginEnabled) 223 if (m_pluginEnabled)
229 { 224 {
230 // we need to capture scene in an anonymous method 225 // we need to capture scene in an anonymous method
231 // here as we need it later in the callbacks 226 // here as we need it later in the callbacks
@@ -233,8 +228,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
233 { 228 {
234 OnRegisterCaps(scene, agentID, caps); 229 OnRegisterCaps(scene, agentID, caps);
235 }; 230 };
236
237
238 231
239 try 232 try
240 { 233 {
@@ -254,16 +247,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
254 m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); 247 m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
255 } 248 }
256 } 249 }
257
258 } 250 }
259 } 251 }
260 252
261 public void PostInitialise() 253 public void PostInitialise()
262 { 254 {
263 if (m_pluginEnabled) 255 if (m_pluginEnabled)
264 { 256 {
265 m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); 257 m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene");
266 258
267 // register the voice interface for this module, so the script engine can call us 259 // register the voice interface for this module, so the script engine can call us
268 m_scene.RegisterModuleInterface<IVoiceModule>(this); 260 m_scene.RegisterModuleInterface<IVoiceModule>(this);
269 } 261 }
@@ -282,15 +274,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
282 { 274 {
283 get { return true; } 275 get { return true; }
284 } 276 }
285 277
286 // <summary> 278 // <summary>
287 // implementation of IVoiceModule, called by osSetParcelSIPAddress script function 279 // implementation of IVoiceModule, called by osSetParcelSIPAddress script function
288 // </summary> 280 // </summary>
289 public void setLandSIPAddress(string SIPAddress,UUID GlobalID) 281 public void setLandSIPAddress(string SIPAddress,UUID GlobalID)
290 { 282 {
291 m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}", 283 m_log.DebugFormat("[FreeSwitchVoice]: setLandSIPAddress parcel id {0}: setting sip address {1}",
292 GlobalID, SIPAddress); 284 GlobalID, SIPAddress);
293 285
294 lock (m_ParcelAddress) 286 lock (m_ParcelAddress)
295 { 287 {
296 if (m_ParcelAddress.ContainsKey(GlobalID.ToString())) 288 if (m_ParcelAddress.ContainsKey(GlobalID.ToString()))
@@ -303,18 +295,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
303 } 295 }
304 } 296 }
305 } 297 }
306 298
307 // <summary> 299 // <summary>
308 // OnRegisterCaps is invoked via the scene.EventManager 300 // OnRegisterCaps is invoked via the scene.EventManager
309 // everytime OpenSim hands out capabilities to a client 301 // everytime OpenSim hands out capabilities to a client
310 // (login, region crossing). We contribute two capabilities to 302 // (login, region crossing). We contribute two capabilities to
311 // the set of capabilities handed back to the client: 303 // the set of capabilities handed back to the client:
312 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. 304 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest.
313 // 305 //
314 // ProvisionVoiceAccountRequest allows the client to obtain 306 // ProvisionVoiceAccountRequest allows the client to obtain
315 // the voice account credentials for the avatar it is 307 // the voice account credentials for the avatar it is
316 // controlling (e.g., user name, password, etc). 308 // controlling (e.g., user name, password, etc).
317 // 309 //
318 // ParcelVoiceInfoRequest is invoked whenever the client 310 // ParcelVoiceInfoRequest is invoked whenever the client
319 // changes from one region or parcel to another. 311 // changes from one region or parcel to another.
320 // 312 //
@@ -371,7 +363,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
371 { 363 {
372 System.Threading.Thread.Sleep(2000); 364 System.Threading.Thread.Sleep(2000);
373 avatar = scene.GetScenePresence(agentID); 365 avatar = scene.GetScenePresence(agentID);
374 366
375 if (avatar == null) 367 if (avatar == null)
376 return "<llsd>undef</llsd>"; 368 return "<llsd>undef</llsd>";
377 } 369 }
@@ -407,8 +399,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
407 // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); 399 // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api");
408 LLSDVoiceAccountResponse voiceAccountResponse = 400 LLSDVoiceAccountResponse voiceAccountResponse =
409 new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, 401 new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm,
410 String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, 402 String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress,
411 m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); 403 m_freeSwitchServicePort, m_freeSwitchAPIPrefix));
412 404
413 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 405 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
414 406
@@ -442,7 +434,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
442 string avatarName = avatar.Name; 434 string avatarName = avatar.Name;
443 435
444 // - check whether we have a region channel in our cache 436 // - check whether we have a region channel in our cache
445 // - if not: 437 // - if not:
446 // create it and cache it 438 // create it and cache it
447 // - send it to the client 439 // - send it to the client
448 // - send channel_uri: as "sip:regionID@m_sipDomain" 440 // - send channel_uri: as "sip:regionID@m_sipDomain"
@@ -451,12 +443,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
451 LLSDParcelVoiceInfoResponse parcelVoiceInfo; 443 LLSDParcelVoiceInfoResponse parcelVoiceInfo;
452 string channelUri; 444 string channelUri;
453 445
454 if (null == scene.LandChannel) 446 if (null == scene.LandChannel)
455 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", 447 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
456 scene.RegionInfo.RegionName, avatarName)); 448 scene.RegionInfo.RegionName, avatarName));
457 449
458
459
460 // get channel_uri: check first whether estate 450 // get channel_uri: check first whether estate
461 // settings allow voice, then whether parcel allows 451 // settings allow voice, then whether parcel allows
462 // voice, if all do retrieve or obtain the parcel 452 // voice, if all do retrieve or obtain the parcel
@@ -493,22 +483,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
493 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); 483 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds);
494 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 484 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
495 485
496 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", 486 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}",
497 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); 487 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r);
498 return r; 488 return r;
499 } 489 }
500 catch (Exception e) 490 catch (Exception e)
501 { 491 {
502 m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", 492 m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
503 scene.RegionInfo.RegionName, avatarName, e.Message); 493 scene.RegionInfo.RegionName, avatarName, e.Message);
504 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", 494 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
505 scene.RegionInfo.RegionName, avatarName, e.ToString()); 495 scene.RegionInfo.RegionName, avatarName, e.ToString());
506 496
507 return "<llsd>undef</llsd>"; 497 return "<llsd>undef</llsd>";
508 } 498 }
509 } 499 }
510 500
511
512 /// <summary> 501 /// <summary>
513 /// Callback for a client request for ChatSessionRequest 502 /// Callback for a client request for ChatSessionRequest
514 /// </summary> 503 /// </summary>
@@ -550,7 +539,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
550 string fwdresponsestr = ""; 539 string fwdresponsestr = "";
551 int fwdresponsecode = 200; 540 int fwdresponsecode = 200;
552 string fwdresponsecontenttype = "text/xml"; 541 string fwdresponsecontenttype = "text/xml";
553
554 542
555 HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress); 543 HttpWebRequest forwardreq = (HttpWebRequest)WebRequest.Create(forwardaddress);
556 forwardreq.Method = method; 544 forwardreq.Method = method;
@@ -577,7 +565,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
577 response["content_type"] = fwdresponsecontenttype; 565 response["content_type"] = fwdresponsecontenttype;
578 response["str_response_string"] = fwdresponsestr; 566 response["str_response_string"] = fwdresponsestr;
579 response["int_response_code"] = fwdresponsecode; 567 response["int_response_code"] = fwdresponsecode;
580 568
581 return response; 569 return response;
582 } 570 }
583 571
@@ -585,11 +573,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
585 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) 573 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request)
586 { 574 {
587 m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called"); 575 m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called");
588 576
589 Hashtable response = new Hashtable(); 577 Hashtable response = new Hashtable();
590 response["content_type"] = "text/xml"; 578 response["content_type"] = "text/xml";
591 response["keepalive"] = false; 579 response["keepalive"] = false;
592 580
593 response["str_response_string"] = String.Format( 581 response["str_response_string"] = String.Format(
594 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + 582 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
595 "<VCConfiguration>\r\n"+ 583 "<VCConfiguration>\r\n"+
@@ -607,9 +595,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
607 "</VCConfiguration>", 595 "</VCConfiguration>",
608 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN, 596 m_freeSwitchRealm, m_freeSwitchSIPProxy, m_freeSwitchAttemptUseSTUN,
609 m_freeSwitchEchoServer, m_freeSwitchEchoPort, 597 m_freeSwitchEchoServer, m_freeSwitchEchoPort,
610 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout, 598 m_freeSwitchDefaultWellKnownIP, m_freeSwitchDefaultTimeout,
611 m_freeSwitchUrlResetPassword, ""); 599 m_freeSwitchUrlResetPassword, "");
612 600
613 response["int_response_code"] = 200; 601 response["int_response_code"] = 200;
614 602
615 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); 603 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]);
@@ -624,7 +612,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
624 response["content-type"] = "text/xml"; 612 response["content-type"] = "text/xml";
625 613
626 Hashtable requestBody = parseRequestBody((string)request["body"]); 614 Hashtable requestBody = parseRequestBody((string)request["body"]);
627 615
628 if (!requestBody.ContainsKey("auth_token")) 616 if (!requestBody.ContainsKey("auth_token"))
629 return response; 617 return response;
630 618
@@ -632,7 +620,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
632 //string[] auth_tokenvals = auth_token.Split(':'); 620 //string[] auth_tokenvals = auth_token.Split(':');
633 //string username = auth_tokenvals[0]; 621 //string username = auth_tokenvals[0];
634 int strcount = 0; 622 int strcount = 0;
635 623
636 string[] ids = new string[strcount]; 624 string[] ids = new string[strcount];
637 625
638 int iter = -1; 626 int iter = -1;
@@ -648,7 +636,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
648 } 636 }
649 StringBuilder resp = new StringBuilder(); 637 StringBuilder resp = new StringBuilder();
650 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">"); 638 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">");
651 639
652 resp.Append(string.Format(@"<level0> 640 resp.Append(string.Format(@"<level0>
653 <status>OK</status> 641 <status>OK</status>
654 <cookie_name>lib_session</cookie_name> 642 <cookie_name>lib_session</cookie_name>
@@ -678,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
678 <b2g_group_id></b2g_group_id> 666 <b2g_group_id></b2g_group_id>
679 </level3>", ids[i],i,m_freeSwitchRealm,dt)); 667 </level3>", ids[i],i,m_freeSwitchRealm,dt));
680 } 668 }
681 669
682 resp.Append("</buddies><groups></groups></body></level0></response>"); 670 resp.Append("</buddies><groups></groups></body></level0></response>");
683 671
684 response["str_response_string"] = resp.ToString(); 672 response["str_response_string"] = resp.ToString();
@@ -694,7 +682,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
694 string requestbody = (string)request["body"]; 682 string requestbody = (string)request["body"];
695 string uri = (string)request["uri"]; 683 string uri = (string)request["uri"];
696 string contenttype = (string)request["content-type"]; 684 string contenttype = (string)request["content-type"];
697 685
698 Hashtable requestBody = parseRequestBody((string)request["body"]); 686 Hashtable requestBody = parseRequestBody((string)request["body"]);
699 687
700 //string pwd = (string) requestBody["pwd"]; 688 //string pwd = (string) requestBody["pwd"];
@@ -712,7 +700,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
712 pos++; 700 pos++;
713 if (s == userid) 701 if (s == userid)
714 break; 702 break;
715
716 } 703 }
717 } 704 }
718 } 705 }
@@ -735,7 +722,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
735 </body> 722 </body>
736 </level0> 723 </level0>
737 </response>", userid, pos, avatarName); 724 </response>", userid, pos, avatarName);
738 725
739 response["int_response_code"] = 200; 726 response["int_response_code"] = 200;
740 return response; 727 return response;
741 /* 728 /*
@@ -752,13 +739,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
752 public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request) 739 public Hashtable FreeSwitchConfigHTTPHandler(Hashtable request)
753 { 740 {
754 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]); 741 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler called with {0}", (string)request["body"]);
755 742
756 Hashtable response = new Hashtable(); 743 Hashtable response = new Hashtable();
757 response["str_response_string"] = string.Empty; 744 response["str_response_string"] = string.Empty;
758 // all the params come as NVPs in the request body 745 // all the params come as NVPs in the request body
759 Hashtable requestBody = parseRequestBody((string) request["body"]); 746 Hashtable requestBody = parseRequestBody((string) request["body"]);
760 747
761 // is this a dialplan or directory request 748 // is this a dialplan or directory request
762 string section = (string) requestBody["section"]; 749 string section = (string) requestBody["section"];
763 750
764 if (section == "directory") 751 if (section == "directory")
@@ -767,40 +754,39 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
767 response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody); 754 response = m_FreeSwitchDialplan.HandleDialplanRequest(m_freeSwitchContext, m_freeSwitchRealm, requestBody);
768 else 755 else
769 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section); 756 m_log.WarnFormat("[FreeSwitchVoice]: section was {0}", section);
770 757
771 // XXX: re-generate dialplan: 758 // XXX: re-generate dialplan:
772 // - conf == region UUID 759 // - conf == region UUID
773 // - conf number = region port 760 // - conf number = region port
774 // -> TODO Initialise(): keep track of regions via events 761 // -> TODO Initialise(): keep track of regions via events
775 // re-generate accounts for all avatars 762 // re-generate accounts for all avatars
776 // -> TODO Initialise(): keep track of avatars via events 763 // -> TODO Initialise(): keep track of avatars via events
777 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 764 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
778 765
779 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), "")); 766 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchConfigHTTPHandler return {0}",normalizeEndLines.Replace(((string)response["str_response_string"]), ""));
780 return response; 767 return response;
781 } 768 }
782 769
783 public Hashtable parseRequestBody(string body) 770 public Hashtable parseRequestBody(string body)
784 { 771 {
785 Hashtable bodyParams = new Hashtable(); 772 Hashtable bodyParams = new Hashtable();
786 // split string 773 // split string
787 string [] nvps = body.Split(new Char [] {'&'}); 774 string [] nvps = body.Split(new Char [] {'&'});
788 775
789 foreach (string s in nvps) { 776 foreach (string s in nvps)
790 777 {
791 if (s.Trim() != "") 778 if (s.Trim() != "")
792 { 779 {
793 string [] nvp = s.Split(new Char [] {'='}); 780 string [] nvp = s.Split(new Char [] {'='});
794 bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1])); 781 bodyParams.Add(HttpUtility.UrlDecode(nvp[0]), HttpUtility.UrlDecode(nvp[1]));
795 } 782 }
796 } 783 }
797 784
798 return bodyParams; 785 return bodyParams;
799 } 786 }
800 787
801 private string ChannelUri(Scene scene, LandData land) 788 private string ChannelUri(Scene scene, LandData land)
802 { 789 {
803
804 string channelUri = null; 790 string channelUri = null;
805 791
806 string landUUID; 792 string landUUID;
@@ -808,12 +794,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
808 794
809 // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same 795 // Create parcel voice channel. If no parcel exists, then the voice channel ID is the same
810 // as the directory ID. Otherwise, it reflects the parcel's ID. 796 // as the directory ID. Otherwise, it reflects the parcel's ID.
811 797
812 lock (m_ParcelAddress) 798 lock (m_ParcelAddress)
813 { 799 {
814 if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) 800 if (m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
815 { 801 {
816 m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}", 802 m_log.DebugFormat("[FreeSwitchVoice]: parcel id {0}: using sip address {1}",
817 land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]); 803 land.GlobalID, m_ParcelAddress[land.GlobalID.ToString()]);
818 return m_ParcelAddress[land.GlobalID.ToString()]; 804 return m_ParcelAddress[land.GlobalID.ToString()];
819 } 805 }
@@ -823,22 +809,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
823 { 809 {
824 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); 810 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
825 landUUID = land.GlobalID.ToString(); 811 landUUID = land.GlobalID.ToString();
826 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 812 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
827 landName, land.LocalID, landUUID); 813 landName, land.LocalID, landUUID);
828 } 814 }
829 else 815 else
830 { 816 {
831 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); 817 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
832 landUUID = scene.RegionInfo.RegionID.ToString(); 818 landUUID = scene.RegionInfo.RegionID.ToString();
833 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 819 m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
834 landName, land.LocalID, landUUID); 820 landName, land.LocalID, landUUID);
835 } 821 }
836 System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); 822 System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
837 823
838 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables 824 // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables
839 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. 825 // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator.
840 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); 826 channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm);
841 827
842 lock (m_ParcelAddress) 828 lock (m_ParcelAddress)
843 { 829 {
844 if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString())) 830 if (!m_ParcelAddress.ContainsKey(land.GlobalID.ToString()))
@@ -849,14 +835,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
849 835
850 return channelUri; 836 return channelUri;
851 } 837 }
852 838
853 private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) 839 private static bool CustomCertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
854 { 840 {
855
856 return true; 841 return true;
857
858 } 842 }
859 } 843 }
844
860 public class MonoCert : ICertificatePolicy 845 public class MonoCert : ICertificatePolicy
861 { 846 {
862 #region ICertificatePolicy Members 847 #region ICertificatePolicy Members