diff options
author | Adam Frisby | 2008-04-30 21:16:36 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:16:36 +0000 |
commit | f5c312bc3c2567449c7268a54a08a54119f58d53 (patch) | |
tree | 424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/VoiceModule.cs | |
parent | * Adds the AuthbuyerID field to sqlite and makes use of it. (diff) | |
download | opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz |
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.)
* This should be moved into a seperate project file.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/VoiceModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/VoiceModule.cs | 197 |
1 files changed, 0 insertions, 197 deletions
diff --git a/OpenSim/Region/Environment/Modules/VoiceModule.cs b/OpenSim/Region/Environment/Modules/VoiceModule.cs deleted file mode 100644 index 106becd..0000000 --- a/OpenSim/Region/Environment/Modules/VoiceModule.cs +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
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 libsecondlife; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Servers; | ||
37 | using OpenSim.Region.Capabilities; | ||
38 | using OpenSim.Region.Environment.Interfaces; | ||
39 | using OpenSim.Region.Environment.Scenes; | ||
40 | using Caps=OpenSim.Region.Capabilities.Caps; | ||
41 | |||
42 | namespace OpenSim.Region.Environment.Modules | ||
43 | { | ||
44 | public class VoiceModule : IRegionModule | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private Scene m_scene; | ||
50 | private IConfig m_config; | ||
51 | private string m_sipDomain; | ||
52 | |||
53 | private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; | ||
54 | private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; | ||
55 | |||
56 | public void Initialise(Scene scene, IConfigSource config) | ||
57 | { | ||
58 | m_scene = scene; | ||
59 | m_config = config.Configs["Voice"]; | ||
60 | |||
61 | if (null == m_config || !m_config.GetBoolean("enabled", false)) | ||
62 | { | ||
63 | m_log.Info("[VOICE] plugin disabled"); | ||
64 | return; | ||
65 | } | ||
66 | m_log.Info("[VOICE] plugin enabled"); | ||
67 | |||
68 | m_sipDomain = m_config.GetString("sip_domain", String.Empty); | ||
69 | if (String.IsNullOrEmpty(m_sipDomain)) | ||
70 | { | ||
71 | m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); | ||
72 | m_log.Info("[VOICE] plugin disabled"); | ||
73 | return; | ||
74 | } | ||
75 | m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); | ||
76 | |||
77 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
78 | } | ||
79 | |||
80 | public void PostInitialise() | ||
81 | { | ||
82 | } | ||
83 | |||
84 | public void Close() | ||
85 | { | ||
86 | } | ||
87 | |||
88 | public string Name | ||
89 | { | ||
90 | get { return "VoiceModule"; } | ||
91 | } | ||
92 | |||
93 | public bool IsSharedModule | ||
94 | { | ||
95 | get { return false; } | ||
96 | } | ||
97 | |||
98 | public void OnRegisterCaps(LLUUID agentID, Caps caps) | ||
99 | { | ||
100 | m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | ||
101 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
102 | caps.RegisterHandler("ParcelVoiceInfoRequest", | ||
103 | new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, | ||
104 | delegate(string request, string path, string param) | ||
105 | { | ||
106 | return ParcelVoiceInfoRequest(request, path, param, | ||
107 | agentID, caps); | ||
108 | })); | ||
109 | caps.RegisterHandler("ProvisionVoiceAccountRequest", | ||
110 | new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, | ||
111 | delegate(string request, string path, string param) | ||
112 | { | ||
113 | return ProvisionVoiceAccountRequest(request, path, param, | ||
114 | agentID, caps); | ||
115 | })); | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Callback for a client request for ParcelVoiceInfo | ||
120 | /// </summary> | ||
121 | /// <param name="request"></param> | ||
122 | /// <param name="path"></param> | ||
123 | /// <param name="param"></param> | ||
124 | /// <param name="agentID"></param> | ||
125 | /// <param name="caps"></param> | ||
126 | /// <returns></returns> | ||
127 | public string ParcelVoiceInfoRequest(string request, string path, string param, | ||
128 | LLUUID agentID, Caps caps) | ||
129 | { | ||
130 | try | ||
131 | { | ||
132 | m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); | ||
133 | |||
134 | // FIXME: get the creds from region file or from config | ||
135 | Hashtable creds = new Hashtable(); | ||
136 | |||
137 | creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID.ToString(), m_sipDomain); | ||
138 | |||
139 | string regionName = m_scene.RegionInfo.RegionName; | ||
140 | ScenePresence avatar = m_scene.GetScenePresence(agentID); | ||
141 | if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); | ||
142 | LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
143 | |||
144 | LLSDParcelVoiceInfoResponse parcelVoiceInfo = | ||
145 | new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); | ||
146 | |||
147 | string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); | ||
148 | m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); | ||
149 | |||
150 | return r; | ||
151 | } | ||
152 | catch (Exception e) | ||
153 | { | ||
154 | m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); | ||
155 | } | ||
156 | |||
157 | return null; | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// Callback for a client request for Voice Account Details | ||
162 | /// </summary> | ||
163 | /// <param name="request"></param> | ||
164 | /// <param name="path"></param> | ||
165 | /// <param name="param"></param> | ||
166 | /// <param name="agentID"></param> | ||
167 | /// <param name="caps"></param> | ||
168 | /// <returns></returns> | ||
169 | public string ProvisionVoiceAccountRequest(string request, string path, string param, | ||
170 | LLUUID agentID, Caps caps) | ||
171 | { | ||
172 | try | ||
173 | { | ||
174 | m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", | ||
175 | request, path, param); | ||
176 | |||
177 | string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); | ||
178 | voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); | ||
179 | |||
180 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | ||
181 | if (null == userInfo) throw new Exception("cannot get user details"); | ||
182 | |||
183 | LLSDVoiceAccountResponse voiceAccountResponse = | ||
184 | new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); | ||
185 | string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); | ||
186 | m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); | ||
187 | return r; | ||
188 | } | ||
189 | catch (Exception e) | ||
190 | { | ||
191 | m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); | ||
192 | } | ||
193 | |||
194 | return null; | ||
195 | } | ||
196 | } | ||
197 | } | ||