aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs104
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs1
-rw-r--r--OpenSim/Services/FreeswitchService/FreeswitchService.cs359
-rw-r--r--OpenSim/Services/FreeswitchService/FreeswitchServiceBase.cs36
-rw-r--r--OpenSim/Services/Interfaces/IFreeswitchService.cs5
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs4
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs40
9 files changed, 538 insertions, 16 deletions
diff --git a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
new file mode 100644
index 0000000..c9bba0b
--- /dev/null
+++ b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.IO;
31using System.Collections;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using OpenSim.Server.Base;
39using OpenMetaverse;
40
41namespace OpenSim.Services.Connectors
42{
43 public class RemoteFreeswitchConnector : IFreeswitchService
44 {
45 private static readonly ILog m_log =
46 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType);
48
49 private string m_ServerURI = String.Empty;
50
51 public RemoteFreeswitchConnector()
52 {
53 }
54
55 public RemoteFreeswitchConnector(string serverURI)
56 {
57 m_ServerURI = serverURI.TrimEnd('/') + "/region-config";
58 }
59
60 public RemoteFreeswitchConnector(IConfigSource source)
61 {
62 Initialise(source);
63 }
64
65 public virtual void Initialise(IConfigSource source)
66 {
67 IConfig freeswitchConfig = source.Configs["FreeSwitchVoice"];
68 if (freeswitchConfig == null)
69 {
70 m_log.Error("[FREESWITCH CONNECTOR]: FreeSwitchVoice missing from OpenSim.ini");
71 throw new Exception("Freeswitch connector init error");
72 }
73
74 string serviceURI = freeswitchConfig.GetString("FreeswitchServiceURL",
75 String.Empty);
76
77 if (serviceURI == String.Empty)
78 {
79 m_log.Error("[FREESWITCH CONNECTOR]: No FreeswitchServiceURL named in section FreeSwitchVoice");
80 throw new Exception("Freeswitch connector init error");
81 }
82 m_ServerURI = serviceURI.TrimEnd('/') + "/region-config";
83 }
84
85 public Hashtable HandleDirectoryRequest(Hashtable requestBody)
86 {
87 // not used here
88 return new Hashtable();
89 }
90
91 public Hashtable HandleDialplanRequest(Hashtable requestBody)
92 {
93 // not used here
94 return new Hashtable();
95 }
96
97 public string GetJsonConfig()
98 {
99 m_log.DebugFormat("[FREESWITCH CONNECTOR]: Requesting config from {0}", m_ServerURI);
100 return SynchronousRestFormsRequester.MakeRequest("GET",
101 m_ServerURI, String.Empty);
102 }
103 }
104}
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
index 403ee15..88fbda3 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -312,6 +312,7 @@ namespace OpenSim.Services.Connectors
312 { "InvType", item.InvType.ToString() }, 312 { "InvType", item.InvType.ToString() },
313 { "Folder", item.Folder.ToString() }, 313 { "Folder", item.Folder.ToString() },
314 { "CreatorId", item.CreatorId.ToString() }, 314 { "CreatorId", item.CreatorId.ToString() },
315 { "CreatorData", item.CreatorData.ToString() },
315 { "Description", item.Description.ToString() }, 316 { "Description", item.Description.ToString() },
316 { "NextPermissions", item.NextPermissions.ToString() }, 317 { "NextPermissions", item.NextPermissions.ToString() },
317 { "CurrentPermissions", item.CurrentPermissions.ToString() }, 318 { "CurrentPermissions", item.CurrentPermissions.ToString() },
@@ -344,6 +345,7 @@ namespace OpenSim.Services.Connectors
344 { "InvType", item.InvType.ToString() }, 345 { "InvType", item.InvType.ToString() },
345 { "Folder", item.Folder.ToString() }, 346 { "Folder", item.Folder.ToString() },
346 { "CreatorId", item.CreatorId.ToString() }, 347 { "CreatorId", item.CreatorId.ToString() },
348 { "CreatorData", item.CreatorData.ToString() },
347 { "Description", item.Description.ToString() }, 349 { "Description", item.Description.ToString() },
348 { "NextPermissions", item.NextPermissions.ToString() }, 350 { "NextPermissions", item.NextPermissions.ToString() },
349 { "CurrentPermissions", item.CurrentPermissions.ToString() }, 351 { "CurrentPermissions", item.CurrentPermissions.ToString() },
@@ -556,6 +558,7 @@ namespace OpenSim.Services.Connectors
556 item.InvType = int.Parse(data["InvType"].ToString()); 558 item.InvType = int.Parse(data["InvType"].ToString());
557 item.Folder = new UUID(data["Folder"].ToString()); 559 item.Folder = new UUID(data["Folder"].ToString());
558 item.CreatorId = data["CreatorId"].ToString(); 560 item.CreatorId = data["CreatorId"].ToString();
561 item.CreatorData = data["CreatorData"].ToString();
559 item.Description = data["Description"].ToString(); 562 item.Description = data["Description"].ToString();
560 item.NextPermissions = uint.Parse(data["NextPermissions"].ToString()); 563 item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
561 item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString()); 564 item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 21ad4ab..61f3fbe 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -612,6 +612,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
612 { "Name", item.Name }, 612 { "Name", item.Name },
613 { "Description", item.Description }, 613 { "Description", item.Description },
614 { "CreatorID", item.CreatorId }, 614 { "CreatorID", item.CreatorId },
615 { "CreatorData", item.CreatorData },
615 { "ContentType", invContentType }, 616 { "ContentType", invContentType },
616 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 617 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
617 }; 618 };
@@ -776,6 +777,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
776 invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString()); 777 invItem.AssetType = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString());
777 invItem.CreationDate = item["CreationDate"].AsInteger(); 778 invItem.CreationDate = item["CreationDate"].AsInteger();
778 invItem.CreatorId = item["CreatorID"].AsString(); 779 invItem.CreatorId = item["CreatorID"].AsString();
780 invItem.CreatorData = item["CreatorData"].AsString();
779 invItem.CreatorIdAsUuid = item["CreatorID"].AsUUID(); 781 invItem.CreatorIdAsUuid = item["CreatorID"].AsUUID();
780 invItem.Description = item["Description"].AsString(); 782 invItem.Description = item["Description"].AsString();
781 invItem.Folder = item["ParentID"].AsUUID(); 783 invItem.Folder = item["ParentID"].AsUUID();
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 7936cb8..585a30e 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -506,6 +506,7 @@ namespace OpenSim.Services.Connectors.Simulation
506 OSDMap args = new OSDMap(2); 506 OSDMap args = new OSDMap(2);
507 args["sog"] = OSD.FromString(sog.ToXml2()); 507 args["sog"] = OSD.FromString(sog.ToXml2());
508 args["extra"] = OSD.FromString(sog.ExtraToXmlString()); 508 args["extra"] = OSD.FromString(sog.ExtraToXmlString());
509 args["modified"] = OSD.FromBoolean(sog.HasGroupChanged);
509 string state = sog.GetStateSnapshot(); 510 string state = sog.GetStateSnapshot();
510 if (state.Length > 0) 511 if (state.Length > 0)
511 args["state"] = OSD.FromString(state); 512 args["state"] = OSD.FromString(state);
diff --git a/OpenSim/Services/FreeswitchService/FreeswitchService.cs b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
index 0a38300..fe6f5cd 100644
--- a/OpenSim/Services/FreeswitchService/FreeswitchService.cs
+++ b/OpenSim/Services/FreeswitchService/FreeswitchService.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Text;
29using System.Reflection; 30using System.Reflection;
30using Nini.Config; 31using Nini.Config;
31using log4net; 32using log4net;
@@ -33,19 +34,373 @@ using OpenSim.Framework;
33using OpenSim.Data; 34using OpenSim.Data;
34using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
35using OpenMetaverse; 36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
38using System.Collections;
36 39
37namespace OpenSim.Services.FreeswitchService 40namespace OpenSim.Services.FreeswitchService
38{ 41{
39 public class FreeswitchService : FreeswitchServiceBase, IFreeswitchService 42 public class FreeswitchService : FreeswitchServiceBase, IFreeswitchService
40 { 43 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 45
43 public FreeswitchService(IConfigSource config) : base(config) 46 public FreeswitchService(IConfigSource config) : base(config)
44 { 47 {
45 // Perform initilialization here 48 // Perform initilialization here
46 } 49 }
47 50
51 public Hashtable HandleDialplanRequest(Hashtable request)
52 {
53 m_log.DebugFormat("[FreeSwitchVoice] HandleDialplanRequest called with {0}",request.ToString());
54
55 Hashtable response = new Hashtable();
56
57 foreach (DictionaryEntry item in request)
58 {
59 m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}",item.Key, item.Value);
60 }
61
62 string requestcontext = (string) request["Hunt-Context"];
63 response["content_type"] = "text/xml";
64 response["keepalive"] = false;
65 response["int_response_code"] = 200;
66
67 if (m_freeSwitchContext != String.Empty && m_freeSwitchContext != requestcontext)
68 {
69 m_log.Debug("[FreeSwitchDirectory] returning empty as it's for another context");
70 response["str_response_string"] = "";
71 }
72 else
73 {
74 response["str_response_string"] = String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
75 <document type=""freeswitch/xml"">
76 <section name=""dialplan"">
77 <context name=""{0}"">" +
78
79/* <!-- dial via SIP uri -->
80 <extension name=""sip_uri"">
81 <condition field=""destination_number"" expression=""^sip:(.*)$"">
82 <action application=""bridge"" data=""sofia/${use_profile}/$1""/>
83 <!--<action application=""bridge"" data=""$1""/>-->
84 </condition>
85 </extension>*/
86
87 @"<extension name=""opensim_conferences"">
88 <condition field=""destination_number"" expression=""^confctl-(.*)$"">
89 <action application=""answer""/>
90 <action application=""conference"" data=""$1-{1}@{0}""/>
91 </condition>
92 </extension>
93
94 <extension name=""opensim_conf"">
95 <condition field=""destination_number"" expression=""^conf-(.*)$"">
96 <action application=""answer""/>
97 <action application=""conference"" data=""$1-{1}@{0}""/>
98 </condition>
99 </extension>
100
101 <extension name=""avatar"">
102 <condition field=""destination_number"" expression=""^(x.*)$"">
103 <action application=""bridge"" data=""user/$1""/>
104 </condition>
105 </extension>
106
107 </context>
108 </section>
109 </document>", m_freeSwitchContext, m_freeSwitchRealm);
110 }
111
112 return response;
113 }
114
115 public Hashtable HandleDirectoryRequest(Hashtable request)
116 {
117 Hashtable response = new Hashtable();
118 string domain = (string) request["domain"];
119 if (domain != m_freeSwitchRealm) {
120 response["content_type"] = "text/xml";
121 response["keepalive"] = false;
122 response["int_response_code"] = 200;
123 response["str_response_string"] = "";
124 } else {
125 m_log.DebugFormat("[FreeSwitchDirectory] HandleDirectoryRequest called with {0}",request.ToString());
126
127 // information in the request we might be interested in
128
129 // Request 1 sip_auth for users account
130
131 //Event-Calling-Function=sofia_reg_parse_auth
132 //Event-Calling-Line-Number=1494
133 //action=sip_auth
134 //sip_user_agent=Vivox-SDK-2.1.3010.6151-Mac%20(Feb-11-2009/16%3A42%3A41)
135 //sip_auth_username=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==)
136 //sip_auth_realm=9.20.151.43
137 //sip_contact_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D (==)
138 //sip_contact_host=192.168.0.3 // this shouldnt really be a local IP, investigate STUN servers
139 //sip_to_user=xhZuXKmRpECyr2AARJYyGgg%3D%3D
140 //sip_to_host=9.20.151.43
141 //sip_auth_method=REGISTER
142 //user=xhZuXKmRpECyr2AARJYyGgg%3D%3D
143 //domain=9.20.151.43
144 //ip=9.167.220.137 // this is the correct IP rather than sip_contact_host above when through a vpn or NAT setup
145
146 foreach (DictionaryEntry item in request)
147 {
148 m_log.InfoFormat("[FreeSwitchDirectory] requestBody item {0} {1}", item.Key, item.Value);
149 }
150
151 string eventCallingFunction = (string) request["Event-Calling-Function"];
152 if (eventCallingFunction == null)
153 {
154 eventCallingFunction = "sofia_reg_parse_auth";
155 }
156
157 if (eventCallingFunction.Length == 0)
158 {
159 eventCallingFunction = "sofia_reg_parse_auth";
160 }
161
162 if (eventCallingFunction == "sofia_reg_parse_auth")
163 {
164 string sipAuthMethod = (string)request["sip_auth_method"];
165
166 if (sipAuthMethod == "REGISTER")
167 {
168 response = HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request);
169 }
170 else if (sipAuthMethod == "INVITE")
171 {
172 response = HandleInvite(m_freeSwitchContext, m_freeSwitchRealm, request);
173 }
174 else
175 {
176 m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown sip_auth_method {0}",sipAuthMethod);
177 response["int_response_code"] = 404;
178 response["content_type"] = "text/xml";
179 response["str_response_string"] = "";
180 }
181 }
182 else if (eventCallingFunction == "switch_xml_locate_user")
183 {
184 response = HandleLocateUser(m_freeSwitchRealm, request);
185 }
186 else if (eventCallingFunction == "user_data_function") // gets called when an avatar to avatar call is made
187 {
188 response = HandleLocateUser(m_freeSwitchRealm, request);
189 }
190 else if (eventCallingFunction == "user_outgoing_channel")
191 {
192 response = HandleRegister(m_freeSwitchContext, m_freeSwitchRealm, request);
193 }
194 else if (eventCallingFunction == "config_sofia") // happens once on freeswitch startup
195 {
196 response = HandleConfigSofia(m_freeSwitchContext, m_freeSwitchRealm, request);
197 }
198 else if (eventCallingFunction == "switch_load_network_lists")
199 {
200 //response = HandleLoadNetworkLists(request);
201 response["int_response_code"] = 404;
202 response["keepalive"] = false;
203 response["content_type"] = "text/xml";
204 response["str_response_string"] = "";
205 }
206 else
207 {
208 m_log.ErrorFormat("[FreeSwitchVoice] HandleDirectoryRequest unknown Event-Calling-Function {0}",eventCallingFunction);
209 response["int_response_code"] = 404;
210 response["keepalive"] = false;
211 response["content_type"] = "text/xml";
212 response["str_response_string"] = "";
213 }
214 }
215 return response;
216 }
217
218 private Hashtable HandleRegister(string Context, string Realm, Hashtable request)
219 {
220 m_log.Info("[FreeSwitchDirectory] HandleRegister called");
221
222 // TODO the password we return needs to match that sent in the request, this is hard coded for now
223 string password = "1234";
224 string domain = (string) request["domain"];
225 string user = (string) request["user"];
226
227 Hashtable response = new Hashtable();
228 response["content_type"] = "text/xml";
229 response["keepalive"] = false;
230 response["int_response_code"] = 200;
231
232 response["str_response_string"] = String.Format(
233 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
234 "<document type=\"freeswitch/xml\">\r\n" +
235 "<section name=\"directory\" description=\"User Directory\">\r\n" +
236 "<domain name=\"{0}\">\r\n" +
237 "<user id=\"{1}\">\r\n" +
238 "<params>\r\n" +
239 "<param name=\"password\" value=\"{2}\" />\r\n" +
240 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${{dialed_user}}@${{dialed_domain}}}}${{sofia_contact(${{dialed_user}}@${{dialed_domain}})}}\"/>\r\n" +
241 "</params>\r\n" +
242 "<variables>\r\n" +
243 "<variable name=\"user_context\" value=\"{3}\" />\r\n" +
244 "<variable name=\"presence_id\" value=\"{1}@{0}\"/>"+
245 "</variables>\r\n" +
246 "</user>\r\n" +
247 "</domain>\r\n" +
248 "</section>\r\n" +
249 "</document>\r\n",
250 domain , user, password, Context);
251
252 return response;
253 }
254
255 private Hashtable HandleInvite(string Context, string Realm, Hashtable request)
256 {
257 m_log.Info("[FreeSwitchDirectory] HandleInvite called");
258
259 // TODO the password we return needs to match that sent in the request, this is hard coded for now
260 string password = "1234";
261 string domain = (string) request["domain"];
262 string user = (string) request["user"];
263 string sipRequestUser = (string) request["sip_request_user"];
264
265 Hashtable response = new Hashtable();
266 response["content_type"] = "text/xml";
267 response["keepalive"] = false;
268 response["int_response_code"] = 200;
269 response["str_response_string"] = String.Format(
270 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
271 "<document type=\"freeswitch/xml\">\r\n" +
272 "<section name=\"directory\" description=\"User Directory\">\r\n" +
273 "<domain name=\"{0}\">\r\n" +
274 "<user id=\"{1}\">\r\n" +
275 "<params>\r\n" +
276 "<param name=\"password\" value=\"{2}\" />\r\n" +
277 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${1}@${{dialed_domain}}}}${{sofia_contact(${1}@${{dialed_domain}})}}\"/>\r\n" +
278 "</params>\r\n" +
279 "<variables>\r\n" +
280 "<variable name=\"user_context\" value=\"{4}\" />\r\n" +
281 "<variable name=\"presence_id\" value=\"{1}@$${{domain}}\"/>"+
282 "</variables>\r\n" +
283 "</user>\r\n" +
284 "<user id=\"{3}\">\r\n" +
285 "<params>\r\n" +
286 "<param name=\"password\" value=\"{2}\" />\r\n" +
287 "<param name=\"dial-string\" value=\"{{sip_contact_user={1}}}{{presence_id=${3}@${{dialed_domain}}}}${{sofia_contact(${3}@${{dialed_domain}})}}\"/>\r\n" +
288 "</params>\r\n" +
289 "<variables>\r\n" +
290 "<variable name=\"user_context\" value=\"{4}\" />\r\n" +
291 "<variable name=\"presence_id\" value=\"{3}@$${{domain}}\"/>"+
292 "</variables>\r\n" +
293 "</user>\r\n" +
294 "</domain>\r\n" +
295 "</section>\r\n" +
296 "</document>\r\n",
297 domain , user, password,sipRequestUser, Context);
298
299 return response;
300 }
48 301
49 // Implement IFreeswitchService here 302 private Hashtable HandleLocateUser(String Realm, Hashtable request)
303 {
304 m_log.Info("[FreeSwitchDirectory] HandleLocateUser called");
305
306 // TODO the password we return needs to match that sent in the request, this is hard coded for now
307 string domain = (string) request["domain"];
308 string user = (string) request["user"];
309
310 Hashtable response = new Hashtable();
311 response["content_type"] = "text/xml";
312 response["keepalive"] = false;
313 response["int_response_code"] = 200;
314 response["str_response_string"] = String.Format(
315 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
316 "<document type=\"freeswitch/xml\">\r\n" +
317 "<section name=\"directory\" description=\"User Directory\">\r\n" +
318 "<domain name=\"{0}\">\r\n" +
319 "<params>\r\n" +
320 "<param name=\"dial-string\" value=\"{{sip_contact_user=${{dialed_user}}}}{{presence_id=${{dialed_user}}@${{dialed_domain}}}}${{sofia_contact(${{dialed_user}}@${{dialed_domain}})}}\"/>\r\n" +
321 "</params>\r\n" +
322 "<user id=\"{1}\">\r\n" +
323 "<variables>\r\n"+
324 "<variable name=\"default_gateway\" value=\"$${{default_provider}}\"/>\r\n"+
325 "<variable name=\"presence_id\" value=\"{1}@$${{domain}}\"/>"+
326 "</variables>\r\n"+
327 "</user>\r\n" +
328 "</domain>\r\n" +
329 "</section>\r\n" +
330 "</document>\r\n",
331 domain , user);
332
333 return response;
334 }
335
336 private Hashtable HandleConfigSofia(string Context, string Realm, Hashtable request)
337 {
338 m_log.Info("[FreeSwitchDirectory] HandleConfigSofia called");
339
340 // TODO the password we return needs to match that sent in the request, this is hard coded for now
341 string domain = (string) request["domain"];
342
343 Hashtable response = new Hashtable();
344 response["content_type"] = "text/xml";
345 response["keepalive"] = false;
346 response["int_response_code"] = 200;
347 response["str_response_string"] = String.Format(
348 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
349 "<document type=\"freeswitch/xml\">\r\n" +
350 "<section name=\"directory\" description=\"User Directory\">\r\n" +
351 "<domain name=\"{0}\">\r\n" +
352 "<params>\r\n" +
353 "<param name=\"dial-string\" value=\"{{sip_contact_user=${{dialed_user}}}}{{presence_id=${{dialed_user}}@${{dialed_domain}}}}${{sofia_contact(${{dialed_user}}@${{dialed_domain}})}}\"/>\r\n" +
354 "</params>\r\n" +
355 "<groups name=\"default\">\r\n"+
356 "<users>\r\n"+
357 "<user id=\"$${{default_provider}}\">\r\n"+
358 "<gateways>\r\n"+
359 "<gateway name=\"$${{default_provider}}\">\r\n"+
360 "<param name=\"username\" value=\"$${{default_provider_username}}\"/>\r\n"+
361 "<param name=\"password\" value=\"$${{default_provider_password}}\"/>\r\n"+
362 "<param name=\"from-user\" value=\"$${{default_provider_username}}\"/>\r\n"+
363 "<param name=\"from-domain\" value=\"$${{default_provider_from_domain}}\"/>\r\n"+
364 "<param name=\"expire-seconds\" value=\"600\"/>\r\n"+
365 "<param name=\"register\" value=\"$${{default_provider_register}}\"/>\r\n"+
366 "<param name=\"retry-seconds\" value=\"30\"/>\r\n"+
367 "<param name=\"extension\" value=\"$${{default_provider_contact}}\"/>\r\n"+
368 "<param name=\"contact-params\" value=\"domain_name=$${{domain}}\"/>\r\n"+
369 "<param name=\"context\" value=\"{1}\"/>\r\n"+
370 "</gateway>\r\n"+
371 "</gateways>\r\n"+
372 "<params>\r\n"+
373 "<param name=\"password\" value=\"$${{default_provider_password}}\"/>\r\n"+
374 "</params>\r\n"+
375 "</user>\r\n"+
376 "</users>"+
377 "</groups>\r\n" +
378 "<variables>\r\n"+
379 "<variable name=\"default_gateway\" value=\"$${{default_provider}}\"/>\r\n"+
380 "</variables>\r\n"+
381 "</domain>\r\n" +
382 "</section>\r\n" +
383 "</document>\r\n",
384 domain, Context);
385
386 return response;
387 }
388
389 public string GetJsonConfig()
390 {
391 OSDMap map = new OSDMap(9);
392
393 map.Add("Realm", m_freeSwitchRealm);
394 map.Add("SIPProxy", m_freeSwitchSIPProxy);
395 map.Add("AttemptUseSTUN", m_freeSwitchAttemptUseSTUN);
396 map.Add("EchoServer", m_freeSwitchEchoServer);
397 map.Add("EchoPort", m_freeSwitchEchoPort);
398 map.Add("DefaultWellKnownIP", m_freeSwitchDefaultWellKnownIP);
399 map.Add("DefaultTimeout", m_freeSwitchDefaultTimeout);
400 map.Add("Context", m_freeSwitchContext);
401 map.Add("APIPrefix", m_freeSwitchAPIPrefix);
402
403 return OSDParser.SerializeJsonString(map);
404 }
50 } 405 }
51} 406}
diff --git a/OpenSim/Services/FreeswitchService/FreeswitchServiceBase.cs b/OpenSim/Services/FreeswitchService/FreeswitchServiceBase.cs
index 83fecef..ebbb1b0 100644
--- a/OpenSim/Services/FreeswitchService/FreeswitchServiceBase.cs
+++ b/OpenSim/Services/FreeswitchService/FreeswitchServiceBase.cs
@@ -31,11 +31,28 @@ using Nini.Config;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
33using OpenSim.Services.Base; 33using OpenSim.Services.Base;
34using log4net;
34 35
35namespace OpenSim.Services.FreeswitchService 36namespace OpenSim.Services.FreeswitchService
36{ 37{
37 public class FreeswitchServiceBase : ServiceBase 38 public class FreeswitchServiceBase : ServiceBase
38 { 39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
42 protected string m_freeSwitchRealm;
43 protected string m_freeSwitchSIPProxy;
44 protected bool m_freeSwitchAttemptUseSTUN = false;
45 protected string m_freeSwitchEchoServer;
46 protected int m_freeSwitchEchoPort = 50505;
47 protected string m_freeSwitchDefaultWellKnownIP;
48 protected int m_freeSwitchDefaultTimeout = 5000;
49 protected string m_freeSwitchContext = "default";
50 protected string m_freeSwitchServerUser = "freeswitch";
51 protected string m_freeSwitchServerPass = "password";
52 protected readonly string m_freeSwitchAPIPrefix = "/fsapi";
53
54 protected bool m_Enabled = false;
55
39 public FreeswitchServiceBase(IConfigSource config) : base(config) 56 public FreeswitchServiceBase(IConfigSource config) : base(config)
40 { 57 {
41 // 58 //
@@ -44,7 +61,24 @@ namespace OpenSim.Services.FreeswitchService
44 IConfig freeswitchConfig = config.Configs["FreeswitchService"]; 61 IConfig freeswitchConfig = config.Configs["FreeswitchService"];
45 if (freeswitchConfig != null) 62 if (freeswitchConfig != null)
46 { 63 {
47 // Read config here !! 64 m_freeSwitchDefaultWellKnownIP = freeswitchConfig.GetString("ServerAddress", String.Empty);
65 if (m_freeSwitchDefaultWellKnownIP == String.Empty)
66 {
67 m_log.Error("[FREESWITCH]: No FreeswitchServerAddress given, can't continue");
68 return;
69 }
70
71 m_freeSwitchRealm = freeswitchConfig.GetString("Realm", m_freeSwitchDefaultWellKnownIP);
72 m_freeSwitchSIPProxy = freeswitchConfig.GetString("SIPProxy", m_freeSwitchDefaultWellKnownIP + ":5060");
73 m_freeSwitchEchoServer = freeswitchConfig.GetString("EchoServer", m_freeSwitchDefaultWellKnownIP);
74 m_freeSwitchEchoPort = freeswitchConfig.GetInt("EchoPort", m_freeSwitchEchoPort);
75 m_freeSwitchAttemptUseSTUN = freeswitchConfig.GetBoolean("AttemptSTUN", false); // This may not work
76 m_freeSwitchDefaultTimeout = freeswitchConfig.GetInt("DefaultTimeout", m_freeSwitchDefaultTimeout);
77 m_freeSwitchContext = freeswitchConfig.GetString("Context", m_freeSwitchContext);
78 m_freeSwitchServerUser = freeswitchConfig.GetString("UserName", m_freeSwitchServerUser);
79 m_freeSwitchServerPass = freeswitchConfig.GetString("Password", m_freeSwitchServerPass);
80
81 m_Enabled = true;
48 } 82 }
49 } 83 }
50 } 84 }
diff --git a/OpenSim/Services/Interfaces/IFreeswitchService.cs b/OpenSim/Services/Interfaces/IFreeswitchService.cs
index d1f635b..e7941d5 100644
--- a/OpenSim/Services/Interfaces/IFreeswitchService.cs
+++ b/OpenSim/Services/Interfaces/IFreeswitchService.cs
@@ -27,11 +27,14 @@
27 27
28using System; 28using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using System.Collections;
30 31
31namespace OpenSim.Services.Interfaces 32namespace OpenSim.Services.Interfaces
32{ 33{
33 public interface IFreeswitchService 34 public interface IFreeswitchService
34 { 35 {
35 // Place anything the connector eeds to access here! 36 Hashtable HandleDirectoryRequest(Hashtable requestBody);
37 Hashtable HandleDialplanRequest(Hashtable requestBody);
38 string GetJsonConfig();
36 } 39 }
37} 40}
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index fb395ec..e602412 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -524,7 +524,7 @@ namespace OpenSim.Services.InventoryService
524 newItem.ID = item.inventoryID; 524 newItem.ID = item.inventoryID;
525 newItem.InvType = item.invType; 525 newItem.InvType = item.invType;
526 newItem.Folder = item.parentFolderID; 526 newItem.Folder = item.parentFolderID;
527 newItem.CreatorId = item.creatorID; 527 newItem.CreatorIdentification = item.creatorID;
528 newItem.Description = item.inventoryDescription; 528 newItem.Description = item.inventoryDescription;
529 newItem.NextPermissions = (uint)item.inventoryNextPermissions; 529 newItem.NextPermissions = (uint)item.inventoryNextPermissions;
530 newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions; 530 newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions;
@@ -555,7 +555,7 @@ namespace OpenSim.Services.InventoryService
555 newItem.inventoryID = item.ID; 555 newItem.inventoryID = item.ID;
556 newItem.invType = item.InvType; 556 newItem.invType = item.InvType;
557 newItem.parentFolderID = item.Folder; 557 newItem.parentFolderID = item.Folder;
558 newItem.creatorID = item.CreatorId; 558 newItem.creatorID = item.CreatorIdentification;
559 newItem.inventoryDescription = item.Description; 559 newItem.inventoryDescription = item.Description;
560 newItem.inventoryNextPermissions = (int)item.NextPermissions; 560 newItem.inventoryNextPermissions = (int)item.NextPermissions;
561 newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions; 561 newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions;
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index f6ee9ac..e2d1f04 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
33using System.Text.RegularExpressions; 34using System.Text.RegularExpressions;
@@ -427,12 +428,9 @@ namespace OpenSim.Services.LLLoginService
427 { 428 {
428 m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", 429 m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
429 account.FirstName, account.LastName); 430 account.FirstName, account.LastName);
430 defaults = m_GridService.GetRegionsByName(scopeID, "", 1); 431 region = FindAlternativeRegion(scopeID);
431 if (defaults != null && defaults.Count > 0) 432 if (region != null)
432 {
433 region = defaults[0];
434 where = "safe"; 433 where = "safe";
435 }
436 } 434 }
437 } 435 }
438 436
@@ -459,12 +457,9 @@ namespace OpenSim.Services.LLLoginService
459 else 457 else
460 { 458 {
461 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); 459 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
462 defaults = m_GridService.GetRegionsByName(scopeID, "", 1); 460 region = FindAlternativeRegion(scopeID);
463 if (defaults != null && defaults.Count > 0) 461 if (region != null)
464 {
465 region = defaults[0];
466 where = "safe"; 462 where = "safe";
467 }
468 } 463 }
469 464
470 } 465 }
@@ -564,6 +559,31 @@ namespace OpenSim.Services.LLLoginService
564 559
565 } 560 }
566 561
562 private GridRegion FindAlternativeRegion(UUID scopeID)
563 {
564 List<GridRegion> hyperlinks = null;
565 List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
566 if (regions != null && regions.Count > 0)
567 {
568 hyperlinks = m_GridService.GetHyperlinks(scopeID);
569 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
570 if (availableRegions.Count() > 0)
571 return availableRegions.ElementAt(0);
572 }
573 // No fallbacks, try to find an arbitrary region that is not a hyperlink
574 // maxNumber is fixed for now; maybe use some search pattern with increasing maxSize here?
575 regions = m_GridService.GetRegionsByName(scopeID, "", 10);
576 if (regions != null && regions.Count > 0)
577 {
578 if (hyperlinks == null)
579 hyperlinks = m_GridService.GetHyperlinks(scopeID);
580 IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
581 if (availableRegions.Count() > 0)
582 return availableRegions.ElementAt(0);
583 }
584 return null;
585 }
586
567 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper) 587 private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper)
568 { 588 {
569 m_log.Debug("attempting to findforeignregion " + domainName + ":" + port.ToString() + ":" + regionName); 589 m_log.Debug("attempting to findforeignregion " + domainName + ":" + port.ToString() + ":" + regionName);