From 106fd2f616cdd7086cf55325faf78b597d11f092 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 18:41:24 +0000 Subject: * From: Dr Scofield * (and Ansgar/Ansi) * Fleshes out the voice stubs to better interact with the viewer CAPS requests - no actual voice support yet! * In his own words "the attached patch enhances the existing voice support by returning a proper voice account user and password and is preparing the config file so that we can specify a SIP server (not yet working). currently the SIP is hardcoded. the next step is to refactor voice support into a region module. working on that. " --- .../Framework/Communications/Capabilities/Caps.cs | 132 +++++++++------------ .../Capabilities/LLSDParcelVoiceInfoResponse.cs | 52 ++++++++ .../Capabilities/LLSDVoiceAccountResponse.cs | 49 ++++++++ OpenSim/Region/Application/OpenSimMain.cs | 9 ++ OpenSim/Region/Environment/Scenes/Scene.cs | 2 + 5 files changed, 170 insertions(+), 74 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index c9e7507..66de991 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -55,6 +55,12 @@ 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); @@ -67,7 +73,7 @@ namespace OpenSim.Region.Capabilities /// private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } - + private static readonly string m_requestPath = "0000/"; private static readonly string m_mapLayerPath = "0001/"; private static readonly string m_newInventory = "0002/"; @@ -93,6 +99,7 @@ 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) @@ -436,98 +443,75 @@ namespace OpenSim.Region.Capabilities return null; } - - public string ParcelVoiceInfoRequest(string request, string path, string param) - { + /// + /// Callback for a client request for ParcelVoiceInfo + /// + /// + /// + /// + /// + public string ParcelVoiceInfoRequest(string request, string path, string param) { try { - m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - - //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); - //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - - //string capsBase = "/CAPS/" + m_capsObjectPath; - //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - //TaskInventoryScriptUpdater uploader = - //new TaskInventoryScriptUpdater( - //llsdUpdateRequest.item_id, - //llsdUpdateRequest.task_id, - //llsdUpdateRequest.is_script_running, - //capsBase + uploaderPath, - //m_httpListener, - //m_dumpAssetsToFile); - //uploader.OnUpLoad += TaskScriptUpdated; - - //m_httpListener.AddStreamHandler( - //new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - //string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + - //uploaderPath; - - //LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - //uploadResponse.uploader = uploaderURL; - //uploadResponse.state = "upload"; - - // m_log.InfoFormat("[CAPS]: " + - // "ScriptTaskInventory response: {0}", - // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply("parcel_local_id16region_nameTeravus Testvoice_credentialschannel_urisip:conference@192.168.1.127\nsip:user@192.168.1.127"); + 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; } - public string ProvisionVoiceAccountRequest(string request, string path, string param) - { + /// + /// Callback for a client request for Voice Account Details + /// + /// + /// + /// + /// + public string ProvisionVoiceAccountRequest(string request, string path, string param) { try { - m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); - - //Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); - //LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); - //LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - - //string capsBase = "/CAPS/" + m_capsObjectPath; - //string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - //TaskInventoryScriptUpdater uploader = - //new TaskInventoryScriptUpdater( - //llsdUpdateRequest.item_id, - //llsdUpdateRequest.task_id, - //llsdUpdateRequest.is_script_running, - //capsBase + uploaderPath, - //m_httpListener, - //m_dumpAssetsToFile); - //uploader.OnUpLoad += TaskScriptUpdated; - - //m_httpListener.AddStreamHandler( - //new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - //string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + - //uploaderPath; - - //LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - //uploadResponse.uploader = uploaderURL; - //uploadResponse.state = "upload"; - - // m_log.InfoFormat("[CAPS]: " + - // "ScriptTaskInventory response: {0}", - // LLSDHelpers.SerialiseLLSDReply(uploadResponse))); - - return LLSDHelpers.SerialiseLLSDReply("eventsbodymajor_version1minor_version0region_nameTeravus TestmessageRequiredVoiceVersionid152477222"); + 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]: " + e.ToString()); + 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/LLSDParcelVoiceInfoResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs new file mode 100644 index 0000000..4fb0544 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDParcelVoiceInfoResponse.cs @@ -0,0 +1,52 @@ +/* +* 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.Collections; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDParcelVoiceInfoResponse + { + public int parcel_local_id; + public string region_name; + public Hashtable voice_credentials; + + public LLSDParcelVoiceInfoResponse() + { + } + + public LLSDParcelVoiceInfoResponse(string region, int localID, Hashtable creds) + { + region_name = region; + parcel_local_id = localID; + voice_credentials = creds; + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs new file mode 100644 index 0000000..8a18213 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDVoiceAccountResponse.cs @@ -0,0 +1,49 @@ +/* +* 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 libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDVoiceAccountResponse + { + public string username; + public string password; + + public LLSDVoiceAccountResponse() + { + } + + public LLSDVoiceAccountResponse(string user, string pass) + { + username = user; + password = pass; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 60c6127..427fc70 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -240,7 +240,16 @@ namespace OpenSim { config.Set("enabled", "false"); } + + if (DefaultConfig.Configs["Voice"] == null) + DefaultConfig.AddConfig("Voice"); + config = DefaultConfig.Configs["Voice"]; + if (config != null) + { + config.Set("enabled", "false"); + } return DefaultConfig; + } protected void ReadConfigSettings() diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2f277f9..2fa0459 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1590,6 +1590,7 @@ namespace OpenSim.Region.Environment.Scenes //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); } + public void HandleRemoveKnownRegionsFromAvatar(LLUUID avatarID, List regionslst) { ScenePresence av = GetScenePresence(avatarID); @@ -1740,6 +1741,7 @@ namespace OpenSim.Region.Environment.Scenes cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; + cap.CAPSGetUserDetails = CommsManager.UserProfileCacheService.GetUserDetails; m_capsHandlers[agentId] = cap; } -- cgit v1.1