diff options
author | Justin Clarke Casey | 2008-04-03 15:44:20 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-04-03 15:44:20 +0000 |
commit | 042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4 (patch) | |
tree | 347f7abdb075b4acba5ece213d667c7c562c99fb /OpenSim/Region | |
parent | * Minor: fix doc glitch (diff) | |
download | opensim-SC_OLD-042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4.zip opensim-SC_OLD-042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4.tar.gz opensim-SC_OLD-042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4.tar.bz2 opensim-SC_OLD-042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4.tar.xz |
* From: Dr Scofield <hud@zurich.ibm.com>
* This patch removes voice code into a region module. This required the implementation of events and other code to allow region modules to register their own caps handlers, and should allow different voice module implementations.
* CAVEAT: This does not provide complete voice support, it merely provides the hooks so that it can be plugged in.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/VoiceModule.cs | 196 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 34 |
3 files changed, 234 insertions, 2 deletions
diff --git a/OpenSim/Region/Environment/Modules/VoiceModule.cs b/OpenSim/Region/Environment/Modules/VoiceModule.cs new file mode 100644 index 0000000..b254507 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/VoiceModule.cs | |||
@@ -0,0 +1,196 @@ | |||
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.Collections.Generic; | ||
31 | using libsecondlife; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Region.Capabilities; | ||
37 | using Caps = OpenSim.Region.Capabilities.Caps; | ||
38 | using OpenSim.Region.Environment.Interfaces; | ||
39 | using OpenSim.Region.Environment.Scenes; | ||
40 | |||
41 | namespace OpenSim.Region.Environment.Modules | ||
42 | { | ||
43 | public class VoiceModule : IRegionModule | ||
44 | { | ||
45 | private static readonly log4net.ILog m_log = | ||
46 | log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private Scene m_scene; | ||
49 | private IConfig m_config; | ||
50 | private string m_sipDomain; | ||
51 | |||
52 | private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; | ||
53 | private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; | ||
54 | |||
55 | public void Initialise(Scene scene, IConfigSource config) | ||
56 | { | ||
57 | m_scene = scene; | ||
58 | m_config = config.Configs["Voice"]; | ||
59 | |||
60 | if (null == m_config || !m_config.GetBoolean("enabled", false)) | ||
61 | { | ||
62 | m_log.Info("[VOICE] plugin disabled"); | ||
63 | return; | ||
64 | } | ||
65 | m_log.Info("[VOICE] plugin enabled"); | ||
66 | |||
67 | m_sipDomain = m_config.GetString("sip_domain", String.Empty); | ||
68 | if (String.IsNullOrEmpty(m_sipDomain)) | ||
69 | { | ||
70 | m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); | ||
71 | m_log.Info("[VOICE] plugin disabled"); | ||
72 | return; | ||
73 | } | ||
74 | m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); | ||
75 | |||
76 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
77 | } | ||
78 | |||
79 | public void PostInitialise() | ||
80 | { | ||
81 | } | ||
82 | |||
83 | public void Close() | ||
84 | { | ||
85 | } | ||
86 | |||
87 | public string Name | ||
88 | { | ||
89 | get { return "VoiceModule"; } | ||
90 | } | ||
91 | |||
92 | public bool IsSharedModule | ||
93 | { | ||
94 | get { return false; } | ||
95 | } | ||
96 | |||
97 | public void OnRegisterCaps(LLUUID agentID, Caps caps) | ||
98 | { | ||
99 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
100 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
101 | caps.RegisterHandler("ParcelVoiceInfoRequest", | ||
102 | new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, | ||
103 | delegate(string request, string path, string param) | ||
104 | { | ||
105 | return ParcelVoiceInfoRequest(request, path, param, | ||
106 | agentID, caps); | ||
107 | })); | ||
108 | caps.RegisterHandler("ProvisionVoiceAccountRequest", | ||
109 | new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, | ||
110 | delegate(string request, string path, string param) | ||
111 | { | ||
112 | return ProvisionVoiceAccountRequest(request, path, param, | ||
113 | agentID, caps); | ||
114 | })); | ||
115 | } | ||
116 | |||
117 | /// <summary> | ||
118 | /// Callback for a client request for ParcelVoiceInfo | ||
119 | /// </summary> | ||
120 | /// <param name="request"></param> | ||
121 | /// <param name="path"></param> | ||
122 | /// <param name="param"></param> | ||
123 | /// <param name="agentID"></param> | ||
124 | /// <param name="caps"></param> | ||
125 | /// <returns></returns> | ||
126 | public string ParcelVoiceInfoRequest(string request, string path, string param, | ||
127 | LLUUID agentID, Caps caps) | ||
128 | { | ||
129 | try | ||
130 | { | ||
131 | m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
132 | |||
133 | // FIXME: get the creds from region file or from config | ||
134 | Hashtable creds = new Hashtable(); | ||
135 | |||
136 | creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID.ToString(), m_sipDomain); | ||
137 | |||
138 | string regionName = m_scene.RegionInfo.RegionName; | ||
139 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
140 | if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); | ||
141 | LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
142 | |||
143 | LLSDParcelVoiceInfoResponse parcelVoiceInfo = | ||
144 | new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); | ||
145 | |||
146 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | ||
147 | m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); | ||
148 | |||
149 | return r; | ||
150 | } | ||
151 | catch (Exception e) | ||
152 | { | ||
153 | m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); | ||
154 | } | ||
155 | |||
156 | return null; | ||
157 | } | ||
158 | |||
159 | /// <summary> | ||
160 | /// Callback for a client request for Voice Account Details | ||
161 | /// </summary> | ||
162 | /// <param name="request"></param> | ||
163 | /// <param name="path"></param> | ||
164 | /// <param name="param"></param> | ||
165 | /// <param name="agentID"></param> | ||
166 | /// <param name="caps"></param> | ||
167 | /// <returns></returns> | ||
168 | public string ProvisionVoiceAccountRequest(string request, string path, string param, | ||
169 | LLUUID agentID, Caps caps) | ||
170 | { | ||
171 | try | ||
172 | { | ||
173 | m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", | ||
174 | request, path, param); | ||
175 | |||
176 | string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); | ||
177 | voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); | ||
178 | |||
179 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
180 | if (null == userInfo) throw new Exception("cannot get user details"); | ||
181 | |||
182 | LLSDVoiceAccountResponse voiceAccountResponse = | ||
183 | new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash); | ||
184 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | ||
185 | m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); | ||
186 | return r; | ||
187 | } | ||
188 | catch (Exception e) | ||
189 | { | ||
190 | m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); | ||
191 | } | ||
192 | |||
193 | return null; | ||
194 | } | ||
195 | } | ||
196 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2237922..64c443d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1737,14 +1737,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
1737 | Caps cap = | 1737 | Caps cap = |
1738 | new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, | 1738 | new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, |
1739 | capsObjectPath, agentId, m_dumpAssetsToFile); | 1739 | capsObjectPath, agentId, m_dumpAssetsToFile); |
1740 | |||
1741 | cap.RegisterHandlers(); | 1740 | cap.RegisterHandlers(); |
1741 | |||
1742 | EventManager.TriggerOnRegisterCaps(agentId, cap); | ||
1742 | 1743 | ||
1743 | cap.AddNewInventoryItem = AddInventoryItem; | 1744 | cap.AddNewInventoryItem = AddInventoryItem; |
1744 | cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; | 1745 | cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; |
1745 | cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; | 1746 | cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; |
1746 | cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; | 1747 | cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; |
1747 | cap.CAPSGetUserDetails = CommsManager.UserProfileCacheService.GetUserDetails; | ||
1748 | 1748 | ||
1749 | m_capsHandlers[agentId] = cap; | 1749 | m_capsHandlers[agentId] = cap; |
1750 | } | 1750 | } |
@@ -1764,6 +1764,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1764 | agentId, RegionInfo.RegionName); | 1764 | agentId, RegionInfo.RegionName); |
1765 | 1765 | ||
1766 | m_capsHandlers[agentId].DeregisterHandlers(); | 1766 | m_capsHandlers[agentId].DeregisterHandlers(); |
1767 | EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); | ||
1768 | |||
1767 | m_capsHandlers.Remove(agentId); | 1769 | m_capsHandlers.Remove(agentId); |
1768 | } | 1770 | } |
1769 | else | 1771 | else |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 809507c..c916009 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -29,6 +29,7 @@ using libsecondlife; | |||
29 | using System; | 29 | using System; |
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | using Caps = OpenSim.Region.Capabilities.Caps; | ||
32 | 33 | ||
33 | namespace OpenSim.Region.Environment.Scenes | 34 | namespace OpenSim.Region.Environment.Scenes |
34 | { | 35 | { |
@@ -136,6 +137,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
136 | 137 | ||
137 | public event OnNewPresenceDelegate OnMakeChildAgent; | 138 | public event OnNewPresenceDelegate OnMakeChildAgent; |
138 | 139 | ||
140 | /// <summary> | ||
141 | /// RegisterCapsEvent is called by Scene after the Caps object | ||
142 | /// has been instantiated and before it is return to the | ||
143 | /// client and provides region modules to add their caps. | ||
144 | /// </summary> | ||
145 | public delegate void RegisterCapsEvent(LLUUID agentID, Caps caps); | ||
146 | public event RegisterCapsEvent OnRegisterCaps; | ||
147 | /// <summary> | ||
148 | /// DeregisterCapsEvent is called by Scene when the caps | ||
149 | /// handler for an agent are removed. | ||
150 | /// </summary> | ||
151 | public delegate void DeregisterCapsEvent(LLUUID agentID, Caps caps); | ||
152 | public event DeregisterCapsEvent OnDeregisterCaps; | ||
139 | 153 | ||
140 | public class MoneyTransferArgs : System.EventArgs | 154 | public class MoneyTransferArgs : System.EventArgs |
141 | { | 155 | { |
@@ -191,6 +205,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
191 | private ClientClosed handlerClientClosed = null; //OnClientClosed; | 205 | private ClientClosed handlerClientClosed = null; //OnClientClosed; |
192 | private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; | 206 | private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; |
193 | private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; | 207 | private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; |
208 | private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; | ||
209 | private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; | ||
194 | 210 | ||
195 | public void TriggerOnScriptChangedEvent(uint localID, uint change) | 211 | public void TriggerOnScriptChangedEvent(uint localID, uint change) |
196 | { | 212 | { |
@@ -428,5 +444,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
428 | handlerMakeChildAgent(presence); | 444 | handlerMakeChildAgent(presence); |
429 | } | 445 | } |
430 | } | 446 | } |
447 | |||
448 | public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps) | ||
449 | { | ||
450 | handlerRegisterCaps = OnRegisterCaps; | ||
451 | if (handlerRegisterCaps != null) | ||
452 | { | ||
453 | handlerRegisterCaps(agentID, caps); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps) | ||
458 | { | ||
459 | handlerDeregisterCaps = OnDeregisterCaps; | ||
460 | if (handlerDeregisterCaps != null) | ||
461 | { | ||
462 | handlerDeregisterCaps(agentID, caps); | ||
463 | } | ||
464 | } | ||
431 | } | 465 | } |
432 | } | 466 | } |