aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs398
1 files changed, 199 insertions, 199 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
index 8d9ba6f..1527f1e 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
@@ -1,200 +1,200 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Reflection; 30using System.Reflection;
31using libsecondlife; 31using libsecondlife;
32using log4net; 32using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Region.Capabilities; 37using OpenSim.Region.Capabilities;
38using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
40using Caps=OpenSim.Region.Capabilities.Caps; 40using Caps=OpenSim.Region.Capabilities.Caps;
41 41
42namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice 42namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
43{ 43{
44 public class SIPVoiceModule : IRegionModule 44 public class SIPVoiceModule : IRegionModule
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; 49 private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
50 private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; 50 private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
51 private IConfig m_config; 51 private IConfig m_config;
52 private Scene m_scene; 52 private Scene m_scene;
53 private string m_sipDomain; 53 private string m_sipDomain;
54 54
55 #region IRegionModule Members 55 #region IRegionModule Members
56 56
57 public void Initialise(Scene scene, IConfigSource config) 57 public void Initialise(Scene scene, IConfigSource config)
58 { 58 {
59 m_scene = scene; 59 m_scene = scene;
60 m_config = config.Configs["Voice"]; 60 m_config = config.Configs["Voice"];
61 61
62 if (null == m_config || !m_config.GetBoolean("enabled", false)) 62 if (null == m_config || !m_config.GetBoolean("enabled", false))
63 { 63 {
64 m_log.Info("[VOICE] plugin disabled"); 64 m_log.Info("[VOICE] plugin disabled");
65 return; 65 return;
66 } 66 }
67 m_log.Info("[VOICE] plugin enabled"); 67 m_log.Info("[VOICE] plugin enabled");
68 68
69 m_sipDomain = m_config.GetString("sip_domain", String.Empty); 69 m_sipDomain = m_config.GetString("sip_domain", String.Empty);
70 if (String.IsNullOrEmpty(m_sipDomain)) 70 if (String.IsNullOrEmpty(m_sipDomain))
71 { 71 {
72 m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); 72 m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration");
73 m_log.Info("[VOICE] plugin disabled"); 73 m_log.Info("[VOICE] plugin disabled");
74 return; 74 return;
75 } 75 }
76 m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); 76 m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain);
77 77
78 scene.EventManager.OnRegisterCaps += OnRegisterCaps; 78 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
79 } 79 }
80 80
81 public void PostInitialise() 81 public void PostInitialise()
82 { 82 {
83 } 83 }
84 84
85 public void Close() 85 public void Close()
86 { 86 {
87 } 87 }
88 88
89 public string Name 89 public string Name
90 { 90 {
91 get { return "VoiceModule"; } 91 get { return "VoiceModule"; }
92 } 92 }
93 93
94 public bool IsSharedModule 94 public bool IsSharedModule
95 { 95 {
96 get { return false; } 96 get { return false; }
97 } 97 }
98 98
99 #endregion 99 #endregion
100 100
101 public void OnRegisterCaps(LLUUID agentID, Caps caps) 101 public void OnRegisterCaps(LLUUID agentID, Caps caps)
102 { 102 {
103 m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); 103 m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
104 string capsBase = "/CAPS/" + caps.CapsObjectPath; 104 string capsBase = "/CAPS/" + caps.CapsObjectPath;
105 caps.RegisterHandler("ParcelVoiceInfoRequest", 105 caps.RegisterHandler("ParcelVoiceInfoRequest",
106 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, 106 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath,
107 delegate(string request, string path, string param) 107 delegate(string request, string path, string param)
108 { 108 {
109 return ParcelVoiceInfoRequest(request, path, param, 109 return ParcelVoiceInfoRequest(request, path, param,
110 agentID, caps); 110 agentID, caps);
111 })); 111 }));
112 caps.RegisterHandler("ProvisionVoiceAccountRequest", 112 caps.RegisterHandler("ProvisionVoiceAccountRequest",
113 new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, 113 new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath,
114 delegate(string request, string path, string param) 114 delegate(string request, string path, string param)
115 { 115 {
116 return ProvisionVoiceAccountRequest(request, path, param, 116 return ProvisionVoiceAccountRequest(request, path, param,
117 agentID, caps); 117 agentID, caps);
118 })); 118 }));
119 } 119 }
120 120
121 /// <summary> 121 /// <summary>
122 /// Callback for a client request for ParcelVoiceInfo 122 /// Callback for a client request for ParcelVoiceInfo
123 /// </summary> 123 /// </summary>
124 /// <param name="request"></param> 124 /// <param name="request"></param>
125 /// <param name="path"></param> 125 /// <param name="path"></param>
126 /// <param name="param"></param> 126 /// <param name="param"></param>
127 /// <param name="agentID"></param> 127 /// <param name="agentID"></param>
128 /// <param name="caps"></param> 128 /// <param name="caps"></param>
129 /// <returns></returns> 129 /// <returns></returns>
130 public string ParcelVoiceInfoRequest(string request, string path, string param, 130 public string ParcelVoiceInfoRequest(string request, string path, string param,
131 LLUUID agentID, Caps caps) 131 LLUUID agentID, Caps caps)
132 { 132 {
133 try 133 try
134 { 134 {
135 m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); 135 m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param);
136 136
137 // FIXME: get the creds from region file or from config 137 // FIXME: get the creds from region file or from config
138 Hashtable creds = new Hashtable(); 138 Hashtable creds = new Hashtable();
139 139
140 creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); 140 creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain);
141 141
142 string regionName = m_scene.RegionInfo.RegionName; 142 string regionName = m_scene.RegionInfo.RegionName;
143 ScenePresence avatar = m_scene.GetScenePresence(agentID); 143 ScenePresence avatar = m_scene.GetScenePresence(agentID);
144 if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); 144 if (null == m_scene.LandChannel) throw new Exception("land data not yet available");
145 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 145 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
146 146
147 LLSDParcelVoiceInfoResponse parcelVoiceInfo = 147 LLSDParcelVoiceInfoResponse parcelVoiceInfo =
148 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); 148 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds);
149 149
150 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 150 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
151 m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); 151 m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r);
152 152
153 return r; 153 return r;
154 } 154 }
155 catch (Exception e) 155 catch (Exception e)
156 { 156 {
157 m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); 157 m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString());
158 } 158 }
159 159
160 return null; 160 return null;
161 } 161 }
162 162
163 /// <summary> 163 /// <summary>
164 /// Callback for a client request for Voice Account Details 164 /// Callback for a client request for Voice Account Details
165 /// </summary> 165 /// </summary>
166 /// <param name="request"></param> 166 /// <param name="request"></param>
167 /// <param name="path"></param> 167 /// <param name="path"></param>
168 /// <param name="param"></param> 168 /// <param name="param"></param>
169 /// <param name="agentID"></param> 169 /// <param name="agentID"></param>
170 /// <param name="caps"></param> 170 /// <param name="caps"></param>
171 /// <returns></returns> 171 /// <returns></returns>
172 public string ProvisionVoiceAccountRequest(string request, string path, string param, 172 public string ProvisionVoiceAccountRequest(string request, string path, string param,
173 LLUUID agentID, Caps caps) 173 LLUUID agentID, Caps caps)
174 { 174 {
175 try 175 try
176 { 176 {
177 m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", 177 m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
178 request, path, param); 178 request, path, param);
179 179
180 string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); 180 string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes());
181 voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); 181 voiceUser = voiceUser.Replace('+', '-').Replace('/', '_');
182 182
183 CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 183 CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID);
184 if (null == userInfo) throw new Exception("cannot get user details"); 184 if (null == userInfo) throw new Exception("cannot get user details");
185 185
186 LLSDVoiceAccountResponse voiceAccountResponse = 186 LLSDVoiceAccountResponse voiceAccountResponse =
187 new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); 187 new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash);
188 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 188 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
189 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); 189 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r);
190 return r; 190 return r;
191 } 191 }
192 catch (Exception e) 192 catch (Exception e)
193 { 193 {
194 m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); 194 m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message);
195 } 195 }
196 196
197 return null; 197 return null;
198 } 198 }
199 } 199 }
200} \ No newline at end of file 200} \ No newline at end of file