diff options
author | Dr Scofield | 2009-02-10 13:10:57 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-10 13:10:57 +0000 |
commit | 180be7de07014aa33bc6066f12a0819b731c1c9d (patch) | |
tree | 3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice | |
parent | Stopgap measure: To use gridlaunch, or GUI, start opensim with (diff) | |
download | opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.zip opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2 opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz |
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what
has happened is that OpenSim.Region.Environment.Modules has been split
in two:
- OpenSim.Region.CoreModules: all those modules that are either
directly or indirectly referenced from other OpenSim packages, or
that provide functionality that the OpenSim developer community
considers core functionality:
CoreModules/Agent/AssetTransaction
CoreModules/Agent/Capabilities
CoreModules/Agent/TextureDownload
CoreModules/Agent/TextureSender
CoreModules/Agent/TextureSender/Tests
CoreModules/Agent/Xfer
CoreModules/Avatar/AvatarFactory
CoreModules/Avatar/Chat/ChatModule
CoreModules/Avatar/Combat
CoreModules/Avatar/Currency/SampleMoney
CoreModules/Avatar/Dialog
CoreModules/Avatar/Friends
CoreModules/Avatar/Gestures
CoreModules/Avatar/Groups
CoreModules/Avatar/InstantMessage
CoreModules/Avatar/Inventory
CoreModules/Avatar/Inventory/Archiver
CoreModules/Avatar/Inventory/Transfer
CoreModules/Avatar/Lure
CoreModules/Avatar/ObjectCaps
CoreModules/Avatar/Profiles
CoreModules/Communications/Local
CoreModules/Communications/REST
CoreModules/Framework/EventQueue
CoreModules/Framework/InterfaceCommander
CoreModules/Hypergrid
CoreModules/InterGrid
CoreModules/Scripting/DynamicTexture
CoreModules/Scripting/EMailModules
CoreModules/Scripting/HttpRequest
CoreModules/Scripting/LoadImageURL
CoreModules/Scripting/VectorRender
CoreModules/Scripting/WorldComm
CoreModules/Scripting/XMLRPC
CoreModules/World/Archiver
CoreModules/World/Archiver/Tests
CoreModules/World/Estate
CoreModules/World/Land
CoreModules/World/Permissions
CoreModules/World/Serialiser
CoreModules/World/Sound
CoreModules/World/Sun
CoreModules/World/Terrain
CoreModules/World/Terrain/DefaultEffects
CoreModules/World/Terrain/DefaultEffects/bin
CoreModules/World/Terrain/DefaultEffects/bin/Debug
CoreModules/World/Terrain/Effects
CoreModules/World/Terrain/FileLoaders
CoreModules/World/Terrain/FloodBrushes
CoreModules/World/Terrain/PaintBrushes
CoreModules/World/Terrain/Tests
CoreModules/World/Vegetation
CoreModules/World/Wind
CoreModules/World/WorldMap
- OpenSim.Region.OptionalModules: all those modules that are not core
modules:
OptionalModules/Avatar/Chat/IRC-stuff
OptionalModules/Avatar/Concierge
OptionalModules/Avatar/Voice/AsterixVoice
OptionalModules/Avatar/Voice/SIPVoice
OptionalModules/ContentManagementSystem
OptionalModules/Grid/Interregion
OptionalModules/Python
OptionalModules/SvnSerialiser
OptionalModules/World/NPC
OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs new file mode 100644 index 0000000..3e8a433 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs | |||
@@ -0,0 +1,202 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using OpenMetaverse; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Capabilities; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using Caps=OpenSim.Framework.Communications.Capabilities.Caps; | ||
41 | |||
42 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.SIPVoice | ||
43 | { | ||
44 | public class SIPVoiceModule : IRegionModule | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; | ||
50 | private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; | ||
51 | private IConfig m_config; | ||
52 | private Scene m_scene; | ||
53 | private string m_sipDomain; | ||
54 | |||
55 | #region IRegionModule Members | ||
56 | |||
57 | public void Initialise(Scene scene, IConfigSource config) | ||
58 | { | ||
59 | m_scene = scene; | ||
60 | m_config = config.Configs["Voice"]; | ||
61 | |||
62 | if (null == m_config || !m_config.GetBoolean("enabled", false)) | ||
63 | { | ||
64 | m_log.Info("[VOICE] plugin disabled"); | ||
65 | return; | ||
66 | } | ||
67 | m_log.Info("[VOICE] plugin enabled"); | ||
68 | |||
69 | m_sipDomain = m_config.GetString("sip_domain", String.Empty); | ||
70 | if (String.IsNullOrEmpty(m_sipDomain)) | ||
71 | { | ||
72 | m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); | ||
73 | m_log.Info("[VOICE] plugin disabled"); | ||
74 | return; | ||
75 | } | ||
76 | m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); | ||
77 | |||
78 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
79 | } | ||
80 | |||
81 | public void PostInitialise() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public void Close() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public string Name | ||
90 | { | ||
91 | get { return "VoiceModule"; } | ||
92 | } | ||
93 | |||
94 | public bool IsSharedModule | ||
95 | { | ||
96 | get { return false; } | ||
97 | } | ||
98 | |||
99 | #endregion | ||
100 | |||
101 | public void OnRegisterCaps(UUID agentID, Caps caps) | ||
102 | { | ||
103 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
104 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
105 | caps.RegisterHandler("ParcelVoiceInfoRequest", | ||
106 | new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, | ||
107 | delegate(string request, string path, string param, | ||
108 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
109 | { | ||
110 | return ParcelVoiceInfoRequest(request, path, param, | ||
111 | agentID, caps); | ||
112 | })); | ||
113 | caps.RegisterHandler("ProvisionVoiceAccountRequest", | ||
114 | new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, | ||
115 | delegate(string request, string path, string param, | ||
116 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
117 | { | ||
118 | return ProvisionVoiceAccountRequest(request, path, param, | ||
119 | agentID, caps); | ||
120 | })); | ||
121 | } | ||
122 | |||
123 | /// <summary> | ||
124 | /// Callback for a client request for ParcelVoiceInfo | ||
125 | /// </summary> | ||
126 | /// <param name="request"></param> | ||
127 | /// <param name="path"></param> | ||
128 | /// <param name="param"></param> | ||
129 | /// <param name="agentID"></param> | ||
130 | /// <param name="caps"></param> | ||
131 | /// <returns></returns> | ||
132 | public string ParcelVoiceInfoRequest(string request, string path, string param, | ||
133 | UUID agentID, Caps caps) | ||
134 | { | ||
135 | try | ||
136 | { | ||
137 | m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
138 | |||
139 | // FIXME: get the creds from region file or from config | ||
140 | Hashtable creds = new Hashtable(); | ||
141 | |||
142 | creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); | ||
143 | |||
144 | string regionName = m_scene.RegionInfo.RegionName; | ||
145 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
146 | if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); | ||
147 | LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
148 | |||
149 | LLSDParcelVoiceInfoResponse parcelVoiceInfo = | ||
150 | new LLSDParcelVoiceInfoResponse(regionName, land.LocalID, creds); | ||
151 | |||
152 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | ||
153 | m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); | ||
154 | |||
155 | return r; | ||
156 | } | ||
157 | catch (Exception e) | ||
158 | { | ||
159 | m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); | ||
160 | } | ||
161 | |||
162 | return null; | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Callback for a client request for Voice Account Details | ||
167 | /// </summary> | ||
168 | /// <param name="request"></param> | ||
169 | /// <param name="path"></param> | ||
170 | /// <param name="param"></param> | ||
171 | /// <param name="agentID"></param> | ||
172 | /// <param name="caps"></param> | ||
173 | /// <returns></returns> | ||
174 | public string ProvisionVoiceAccountRequest(string request, string path, string param, | ||
175 | UUID agentID, Caps caps) | ||
176 | { | ||
177 | try | ||
178 | { | ||
179 | m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", | ||
180 | request, path, param); | ||
181 | |||
182 | string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); | ||
183 | voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); | ||
184 | |||
185 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
186 | if (null == userInfo) throw new Exception("cannot get user details"); | ||
187 | |||
188 | LLSDVoiceAccountResponse voiceAccountResponse = | ||
189 | new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); | ||
190 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | ||
191 | m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); | ||
192 | return r; | ||
193 | } | ||
194 | catch (Exception e) | ||
195 | { | ||
196 | m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); | ||
197 | } | ||
198 | |||
199 | return null; | ||
200 | } | ||
201 | } | ||
202 | } | ||