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 +++++++++------------ 1 file changed, 58 insertions(+), 74 deletions(-) (limited to 'OpenSim/Framework/Communications/Capabilities/Caps.cs') 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. /// -- cgit v1.1