diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 53cad668ae..886ca49467 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -55,25 +55,22 @@ namespace OpenSim.Region.Capabilities public delegate List FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); - /// - /// FIXME This is a temporary delegate, and should disappear once the voice code is fleshed out and moved into its - /// own region module. - /// - public delegate CachedUserInfo GetUserDetailsCAPS(LLUUID agentID); - public class Caps { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private string m_httpListenerHostName; private uint m_httpListenPort; - + /// /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. /// private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } + private CapsHandlers m_capsHandlers; + private static readonly string m_requestPath = "0000/"; private static readonly string m_mapLayerPath = "0001/"; private static readonly string m_newInventory = "0002/"; @@ -99,7 +96,6 @@ namespace OpenSim.Region.Capabilities public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; - public GetUserDetailsCAPS CAPSGetUserDetails = null; public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) @@ -111,6 +107,7 @@ namespace OpenSim.Region.Capabilities m_httpListenPort = httpPort; m_agentID = agent; m_dumpAssetsToFile = dumpAssetsToFile; + m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort); } /// @@ -123,27 +120,31 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; try - { - m_httpListener.AddStreamHandler( - new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); - m_httpListener.AddStreamHandler( + { + // the root of all evil + m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); + m_capsHandlers["MapLayer"] = + new LLSDStreamhandler("POST", + capsBase + m_mapLayerPath, + GetMapLayer); + m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler("POST", capsBase + m_newInventory, - NewAgentInventoryRequest)); - - // m_httpListener.AddStreamHandler( - // new LLSDStreamhandler("POST", - // capsBase + m_fetchInventory, - // FetchInventory)); - - - AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); - //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); - AddLegacyCapsHandler(m_httpListener, m_parcelVoiceInfoRequestPath, ParcelVoiceInfoRequest); - AddLegacyCapsHandler(m_httpListener, m_provisionVoiceAccountRequestPath, ProvisionVoiceAccountRequest); - AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); - AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); - AddLegacyCapsHandler(m_httpListener, m_fetchInventoryPath, FetchInventoryRequest); + NewAgentInventoryRequest); + m_capsHandlers["UpdateNotecardAgentInventory"] = + new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); + m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; + m_capsHandlers["UpdateScriptTaskInventory"] = + new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); + m_capsHandlers["FetchInventoryDescendents"] = + new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); + // m_capsHandlers["FetchInventoryDescendents"] = + // new LLSDStreamhandler("POST", + // capsBase + m_fetchInventory, + // FetchInventory)); + // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", + // capsBase + m_requestTexture, + // RequestTexture); } catch (Exception e) { @@ -151,36 +152,30 @@ namespace OpenSim.Region.Capabilities } } + /// + /// Register a handler. This allows modules to register handlers. + /// + /// + /// + public void RegisterHandler(string capName, IRequestHandler handler) + { + m_capsHandlers[capName] = handler; + m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); + } + /// /// Remove all CAPS service handlers. /// - /// FIXME: Would be much nicer to remove and all paths to a single list. However, this is a little awkward - /// than it could be as we set up some handlers differently (legacy and non-legacy) /// /// /// /// public void DeregisterHandlers() { - string capsBase = "/CAPS/" + m_capsObjectPath; - - m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_requestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardUpdatePath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardTaskUpdatePath); - m_httpListener.RemoveStreamHandler("POST", capsBase + m_fetchInventoryPath); - } - - //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] - //Commented out the obsolete as at this time the first caps request can not use the new Caps method - //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. - private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) - { - string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); + foreach(string capsName in m_capsHandlers.Caps) + { + m_capsHandlers.Remove(capsName); + } } /// @@ -193,31 +188,12 @@ namespace OpenSim.Region.Capabilities public string CapsRequest(string request, string path, string param) { //Console.WriteLine("caps request " + request); - string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); + string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); return result; } - /// - /// Return an LLSDCapsDetails listing all the capabilities this server can provide - /// - /// - protected LLSDCapsDetails GetCapabilities() - { - LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + - m_capsObjectPath; - caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; - caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; - caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; - caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath; - caps.FetchInventoryDescendents = capsBaseUrl + m_fetchInventoryPath; - caps.ParcelVoiceInfoRequest = capsBaseUrl + m_parcelVoiceInfoRequestPath; - caps.ProvisionVoiceAccountRequest = capsBaseUrl + m_provisionVoiceAccountRequestPath; - - return caps; - } + // FIXME: these all should probably go into the respective region + // modules public string FetchInventoryRequest(string request, string path, string param) { @@ -443,75 +419,6 @@ namespace OpenSim.Region.Capabilities return null; } - /// - /// Callback for a client request for ParcelVoiceInfo - /// - /// - /// - /// - /// - public string ParcelVoiceInfoRequest(string request, string path, string param) { - try - { - m_log.DebugFormat("[CAPS][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); - - // XXX brutal hack, we need to get channel_uri, region - // name, and parcel_local_id from somewhere - Hashtable creds = new Hashtable(); - - creds["channel_uri"] = "sip:testroom@testserver.com"; - - LLSDParcelVoiceInfoResponse parcelVoiceInfo = - new LLSDParcelVoiceInfoResponse("OpenSim Test", 1, creds); - - // XXX for debugging purposes: - string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[CAPS][PARCELVOICE]: {0}", r); - - return r; - } - catch (Exception e) - { - m_log.Error("[CAPS]: " + e.ToString()); - } - - return null; - } - - /// - /// Callback for a client request for Voice Account Details - /// - /// - /// - /// - /// - public string ProvisionVoiceAccountRequest(string request, string path, string param) { - try - { - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); - - if (null == CAPSGetUserDetails) throw new Exception("CAPSGetUserDetails null"); - - string voiceUser = "x" + Convert.ToBase64String(m_agentID.GetBytes()); - voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); - - CachedUserInfo userInfo = CAPSGetUserDetails(m_agentID); - if (null == userInfo) throw new Exception("CAPSGetUserDetails returned null"); - - LLSDVoiceAccountResponse voiceAccountResponse = - new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash); - string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); - return r; - } - catch (Exception e) - { - m_log.Error("[CAPS][PROVISIONVOICE]: " + e.ToString()); - } - - return null; - } - /// /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. /// diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs new file mode 100755 index 0000000000..a3d6b71f98 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs @@ -0,0 +1,144 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; + +namespace OpenSim.Region.Capabilities +{ + /// + /// CapsHandlers is a cap handler container but also takes + /// care of adding and removing cap handlers to and from the + /// supplied BaseHttpServer. + /// + public class CapsHandlers + { + private Dictionary m_capsHandlers = new Dictionary(); + private BaseHttpServer m_httpListener; + private string m_httpListenerHostName; + private uint m_httpListenerPort; + + /// + /// base HTTP server + /// host name of the HTTP + /// server + /// HTTP port + public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) + { + m_httpListener = httpListener; + m_httpListenerHostName = httpListenerHostname; + m_httpListenerPort = httpListenerPort; + } + + /// + /// Remove the cap handler for a capability. + /// + /// name of the capability of the cap + /// handler to be removed + public void Remove(string capsName) + { + m_capsHandlers.Remove(capsName); + } + + public bool ContainsCap(string cap) + { + return m_capsHandlers.ContainsKey(cap); + } + + /// + /// The indexer allows us to treat the CapsHandlers object + /// in an intuitive dictionary like way. + /// + /// + /// The indexer will throw an exception when you try to + /// retrieve a cap handler for a cap that is not contained in + /// CapsHandlers. + /// + public IRequestHandler this[string idx] + { + get + { + return m_capsHandlers[idx]; + } + + set + { + if (m_capsHandlers.ContainsKey(idx)) + { + m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); + m_capsHandlers.Remove(idx); + } + + if (null == value) return; + + m_capsHandlers[idx] = value; + m_httpListener.AddStreamHandler(value); + } + } + + /// + /// Return the list of cap names for which this CapsHandlers + /// object contains cap handlers. + /// + public string[] Caps + { + get + { + string[] __keys = new string[m_capsHandlers.Keys.Count]; + m_capsHandlers.Keys.CopyTo(__keys, 0); + return __keys; + } + } + + /// + /// Return an LLSD-serializable Hashtable describing the + /// capabilities and their handler details. + /// + public Hashtable CapsDetails + { + get + { + Hashtable caps = new Hashtable(); + string baseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); + foreach (string capsName in m_capsHandlers.Keys) + { + // skip SEED cap + if ("SEED" == capsName) continue; + caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; + } + return caps; + } + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs deleted file mode 100644 index bd1c9da25d..0000000000 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDCapsDetails - { - public string MapLayer = String.Empty; - public string NewFileAgentInventory = String.Empty; - //public string EventQueueGet = String.Empty; - // public string RequestTextureDownload = String.Empty; - // public string ChatSessionRequest = String.Empty; - public string UpdateNotecardAgentInventory = String.Empty; - public string UpdateScriptAgentInventory = String.Empty; - public string UpdateScriptTaskInventory = String.Empty; - public string ParcelVoiceInfoRequest = String.Empty; - public string FetchInventoryDescendents = String.Empty; - public string ProvisionVoiceAccountRequest = String.Empty; - - - public LLSDCapsDetails() - { - } - } -} diff --git a/OpenSim/Region/Environment/Modules/VoiceModule.cs b/OpenSim/Region/Environment/Modules/VoiceModule.cs new file mode 100644 index 0000000000..b2545070f2 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/VoiceModule.cs @@ -0,0 +1,196 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Servers; +using OpenSim.Region.Capabilities; +using Caps = OpenSim.Region.Capabilities.Caps; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.Environment.Modules +{ + public class VoiceModule : IRegionModule + { + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + private IConfig m_config; + private string m_sipDomain; + + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_config = config.Configs["Voice"]; + + if (null == m_config || !m_config.GetBoolean("enabled", false)) + { + m_log.Info("[VOICE] plugin disabled"); + return; + } + m_log.Info("[VOICE] plugin enabled"); + + m_sipDomain = m_config.GetString("sip_domain", String.Empty); + if (String.IsNullOrEmpty(m_sipDomain)) + { + m_log.Error("[VOICE] plugin mis-configured: missing sip_domain configuration"); + m_log.Info("[VOICE] plugin disabled"); + return; + } + m_log.InfoFormat("[VOICE] using SIP domain {0}", m_sipDomain); + + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "VoiceModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void OnRegisterCaps(LLUUID agentID, Caps caps) + { + m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); + string capsBase = "/CAPS/" + caps.CapsObjectPath; + caps.RegisterHandler("ParcelVoiceInfoRequest", + new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, + delegate(string request, string path, string param) + { + return ParcelVoiceInfoRequest(request, path, param, + agentID, caps); + })); + caps.RegisterHandler("ProvisionVoiceAccountRequest", + new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, + delegate(string request, string path, string param) + { + return ProvisionVoiceAccountRequest(request, path, param, + agentID, caps); + })); + } + + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(string request, string path, string param, + LLUUID agentID, Caps caps) + { + try + { + m_log.DebugFormat("[VOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); + + // FIXME: get the creds from region file or from config + Hashtable creds = new Hashtable(); + + creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID.ToString(), m_sipDomain); + + string regionName = m_scene.RegionInfo.RegionName; + ScenePresence avatar = m_scene.GetScenePresence(agentID); + if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); + LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); + + LLSDParcelVoiceInfoResponse parcelVoiceInfo = + new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); + + string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); + m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); + + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); + } + + return null; + } + + /// + /// Callback for a client request for Voice Account Details + /// + /// + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(string request, string path, string param, + LLUUID agentID, Caps caps) + { + try + { + m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", + request, path, param); + + string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); + voiceUser = voiceUser.Replace('+', '-').Replace('/', '_'); + + CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); + if (null == userInfo) throw new Exception("cannot get user details"); + + LLSDVoiceAccountResponse voiceAccountResponse = + new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash); + string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); + m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); + return r; + } + catch (Exception e) + { + m_log.ErrorFormat("[CAPS][PROVISIONVOICE]: {0}, retry later", e.Message); + } + + return null; + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 22379224eb..64c443dd47 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1737,14 +1737,14 @@ namespace OpenSim.Region.Environment.Scenes Caps cap = new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, capsObjectPath, agentId, m_dumpAssetsToFile); - cap.RegisterHandlers(); + + EventManager.TriggerOnRegisterCaps(agentId, cap); cap.AddNewInventoryItem = AddInventoryItem; cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; - cap.CAPSGetUserDetails = CommsManager.UserProfileCacheService.GetUserDetails; m_capsHandlers[agentId] = cap; } @@ -1764,6 +1764,8 @@ namespace OpenSim.Region.Environment.Scenes agentId, RegionInfo.RegionName); m_capsHandlers[agentId].DeregisterHandlers(); + EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); + m_capsHandlers.Remove(agentId); } else diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 809507cac8..c9160096d5 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -29,6 +29,7 @@ using libsecondlife; using System; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; +using Caps = OpenSim.Region.Capabilities.Caps; namespace OpenSim.Region.Environment.Scenes { @@ -136,6 +137,19 @@ namespace OpenSim.Region.Environment.Scenes public event OnNewPresenceDelegate OnMakeChildAgent; + /// + /// RegisterCapsEvent is called by Scene after the Caps object + /// has been instantiated and before it is return to the + /// client and provides region modules to add their caps. + /// + public delegate void RegisterCapsEvent(LLUUID agentID, Caps caps); + public event RegisterCapsEvent OnRegisterCaps; + /// + /// DeregisterCapsEvent is called by Scene when the caps + /// handler for an agent are removed. + /// + public delegate void DeregisterCapsEvent(LLUUID agentID, Caps caps); + public event DeregisterCapsEvent OnDeregisterCaps; public class MoneyTransferArgs : System.EventArgs { @@ -191,6 +205,8 @@ namespace OpenSim.Region.Environment.Scenes private ClientClosed handlerClientClosed = null; //OnClientClosed; private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; + private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; + private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; public void TriggerOnScriptChangedEvent(uint localID, uint change) { @@ -428,5 +444,23 @@ namespace OpenSim.Region.Environment.Scenes handlerMakeChildAgent(presence); } } + + public void TriggerOnRegisterCaps(LLUUID agentID, Caps caps) + { + handlerRegisterCaps = OnRegisterCaps; + if (handlerRegisterCaps != null) + { + handlerRegisterCaps(agentID, caps); + } + } + + public void TriggerOnDeregisterCaps(LLUUID agentID, Caps caps) + { + handlerDeregisterCaps = OnDeregisterCaps; + if (handlerDeregisterCaps != null) + { + handlerDeregisterCaps(agentID, caps); + } + } } } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 5a6ef060cc..bf8a48f84e 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -164,7 +164,7 @@ enabled = false ; changed in future. :-) account_management_server = https://www.bhr.vivox.com/api2 ; Global SIP Server for conference calls -sip_uri = sip:testroom@testserver.com +sip_domain = testserver.com ; Uncomment the following to control the progression of daytime ; in the Sim. The defaults are what is shown below