aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Capabilities/Caps.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-04-03 15:44:20 +0000
committerJustin Clarke Casey2008-04-03 15:44:20 +0000
commit042cd57e948f6e3695d1d5b2b2a473ee77a1e9c4 (patch)
tree347f7abdb075b4acba5ece213d667c7c562c99fb /OpenSim/Framework/Communications/Capabilities/Caps.cs
parent* Minor: fix doc glitch (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs189
1 files changed, 48 insertions, 141 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index 53cad66..886ca49 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -55,25 +55,22 @@ namespace OpenSim.Region.Capabilities
55 public delegate List<InventoryItemBase> FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID, 55 public delegate List<InventoryItemBase> FetchInventoryDescendentsCAPS(LLUUID agentID, LLUUID folderID, LLUUID ownerID,
56 bool fetchFolders, bool fetchItems, int sortOrder); 56 bool fetchFolders, bool fetchItems, int sortOrder);
57 57
58 /// <summary>
59 /// FIXME This is a temporary delegate, and should disappear once the voice code is fleshed out and moved into its
60 /// own region module.
61 /// </summary>
62 public delegate CachedUserInfo GetUserDetailsCAPS(LLUUID agentID);
63
64 public class Caps 58 public class Caps
65 { 59 {
66 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 60 private static readonly log4net.ILog m_log =
67 61 log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
62
68 private string m_httpListenerHostName; 63 private string m_httpListenerHostName;
69 private uint m_httpListenPort; 64 private uint m_httpListenPort;
70 65
71 /// <summary> 66 /// <summary>
72 /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester. 67 /// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester.
73 /// </summary> 68 /// </summary>
74 private string m_capsObjectPath; 69 private string m_capsObjectPath;
75 public string CapsObjectPath { get { return m_capsObjectPath; } } 70 public string CapsObjectPath { get { return m_capsObjectPath; } }
76 71
72 private CapsHandlers m_capsHandlers;
73
77 private static readonly string m_requestPath = "0000/"; 74 private static readonly string m_requestPath = "0000/";
78 private static readonly string m_mapLayerPath = "0001/"; 75 private static readonly string m_mapLayerPath = "0001/";
79 private static readonly string m_newInventory = "0002/"; 76 private static readonly string m_newInventory = "0002/";
@@ -99,7 +96,6 @@ namespace OpenSim.Region.Capabilities
99 public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; 96 public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null;
100 // 97 //
101 public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; 98 public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
102 public GetUserDetailsCAPS CAPSGetUserDetails = null;
103 99
104 public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, 100 public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
105 LLUUID agent, bool dumpAssetsToFile) 101 LLUUID agent, bool dumpAssetsToFile)
@@ -111,6 +107,7 @@ namespace OpenSim.Region.Capabilities
111 m_httpListenPort = httpPort; 107 m_httpListenPort = httpPort;
112 m_agentID = agent; 108 m_agentID = agent;
113 m_dumpAssetsToFile = dumpAssetsToFile; 109 m_dumpAssetsToFile = dumpAssetsToFile;
110 m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort);
114 } 111 }
115 112
116 /// <summary> 113 /// <summary>
@@ -123,27 +120,31 @@ namespace OpenSim.Region.Capabilities
123 string capsBase = "/CAPS/" + m_capsObjectPath; 120 string capsBase = "/CAPS/" + m_capsObjectPath;
124 121
125 try 122 try
126 { 123 {
127 m_httpListener.AddStreamHandler( 124 // the root of all evil
128 new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, GetMapLayer)); 125 m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest);
129 m_httpListener.AddStreamHandler( 126 m_capsHandlers["MapLayer"] =
127 new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST",
128 capsBase + m_mapLayerPath,
129 GetMapLayer);
130 m_capsHandlers["NewFileAgentInventory"] =
130 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", 131 new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
131 capsBase + m_newInventory, 132 capsBase + m_newInventory,
132 NewAgentInventoryRequest)); 133 NewAgentInventoryRequest);
133 134 m_capsHandlers["UpdateNotecardAgentInventory"] =
134 // m_httpListener.AddStreamHandler( 135 new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory);
135 // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST", 136 m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"];
136 // capsBase + m_fetchInventory, 137 m_capsHandlers["UpdateScriptTaskInventory"] =
137 // FetchInventory)); 138 new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory);
138 139 m_capsHandlers["FetchInventoryDescendents"] =
139 140 new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest);
140 AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest); 141 // m_capsHandlers["FetchInventoryDescendents"] =
141 //AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture); 142 // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST",
142 AddLegacyCapsHandler(m_httpListener, m_parcelVoiceInfoRequestPath, ParcelVoiceInfoRequest); 143 // capsBase + m_fetchInventory,
143 AddLegacyCapsHandler(m_httpListener, m_provisionVoiceAccountRequestPath, ProvisionVoiceAccountRequest); 144 // FetchInventory));
144 AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory); 145 // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST",
145 AddLegacyCapsHandler(m_httpListener, m_notecardTaskUpdatePath, ScriptTaskInventory); 146 // capsBase + m_requestTexture,
146 AddLegacyCapsHandler(m_httpListener, m_fetchInventoryPath, FetchInventoryRequest); 147 // RequestTexture);
147 } 148 }
148 catch (Exception e) 149 catch (Exception e)
149 { 150 {
@@ -152,35 +153,29 @@ namespace OpenSim.Region.Capabilities
152 } 153 }
153 154
154 /// <summary> 155 /// <summary>
156 /// Register a handler. This allows modules to register handlers.
157 /// </summary>
158 /// <param name="capName"></param>
159 /// <param name="handler"></param>
160 public void RegisterHandler(string capName, IRequestHandler handler)
161 {
162 m_capsHandlers[capName] = handler;
163 m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path);
164 }
165
166 /// <summary>
155 /// Remove all CAPS service handlers. 167 /// Remove all CAPS service handlers.
156 /// 168 ///
157 /// FIXME: Would be much nicer to remove and all paths to a single list. However, this is a little awkward
158 /// than it could be as we set up some handlers differently (legacy and non-legacy)
159 /// </summary> 169 /// </summary>
160 /// <param name="httpListener"></param> 170 /// <param name="httpListener"></param>
161 /// <param name="path"></param> 171 /// <param name="path"></param>
162 /// <param name="restMethod"></param> 172 /// <param name="restMethod"></param>
163 public void DeregisterHandlers() 173 public void DeregisterHandlers()
164 { 174 {
165 string capsBase = "/CAPS/" + m_capsObjectPath; 175 foreach(string capsName in m_capsHandlers.Caps)
166 176 {
167 m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); 177 m_capsHandlers.Remove(capsName);
168 m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); 178 }
169 m_httpListener.RemoveStreamHandler("POST", capsBase + m_requestPath);
170 m_httpListener.RemoveStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath);
171 m_httpListener.RemoveStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath);
172 m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardUpdatePath);
173 m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardTaskUpdatePath);
174 m_httpListener.RemoveStreamHandler("POST", capsBase + m_fetchInventoryPath);
175 }
176
177 //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
178 //Commented out the obsolete as at this time the first caps request can not use the new Caps method
179 //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays.
180 private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
181 {
182 string capsBase = "/CAPS/" + m_capsObjectPath;
183 httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
184 } 179 }
185 180
186 /// <summary> 181 /// <summary>
@@ -193,31 +188,12 @@ namespace OpenSim.Region.Capabilities
193 public string CapsRequest(string request, string path, string param) 188 public string CapsRequest(string request, string path, string param)
194 { 189 {
195 //Console.WriteLine("caps request " + request); 190 //Console.WriteLine("caps request " + request);
196 string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); 191 string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails);
197 return result; 192 return result;
198 } 193 }
199 194
200 /// <summary> 195 // FIXME: these all should probably go into the respective region
201 /// Return an LLSDCapsDetails listing all the capabilities this server can provide 196 // modules
202 /// </summary>
203 /// <returns></returns>
204 protected LLSDCapsDetails GetCapabilities()
205 {
206 LLSDCapsDetails caps = new LLSDCapsDetails();
207 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" +
208 m_capsObjectPath;
209 caps.MapLayer = capsBaseUrl + m_mapLayerPath;
210 // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture;
211 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
212 caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
213 caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath;
214 caps.UpdateScriptTaskInventory = capsBaseUrl + m_notecardTaskUpdatePath;
215 caps.FetchInventoryDescendents = capsBaseUrl + m_fetchInventoryPath;
216 caps.ParcelVoiceInfoRequest = capsBaseUrl + m_parcelVoiceInfoRequestPath;
217 caps.ProvisionVoiceAccountRequest = capsBaseUrl + m_provisionVoiceAccountRequestPath;
218
219 return caps;
220 }
221 197
222 public string FetchInventoryRequest(string request, string path, string param) 198 public string FetchInventoryRequest(string request, string path, string param)
223 { 199 {
@@ -443,75 +419,6 @@ namespace OpenSim.Region.Capabilities
443 return null; 419 return null;
444 } 420 }
445 421
446 /// <summary>
447 /// Callback for a client request for ParcelVoiceInfo
448 /// </summary>
449 /// <param name="request"></param>
450 /// <param name="path"></param>
451 /// <param name="param"></param>
452 /// <returns></returns>
453 public string ParcelVoiceInfoRequest(string request, string path, string param) {
454 try
455 {
456 m_log.DebugFormat("[CAPS][PARCELVOICE]: request: {0}, path: {1}, param: {2}", request, path, param);
457
458 // XXX brutal hack, we need to get channel_uri, region
459 // name, and parcel_local_id from somewhere
460 Hashtable creds = new Hashtable();
461
462 creds["channel_uri"] = "sip:testroom@testserver.com";
463
464 LLSDParcelVoiceInfoResponse parcelVoiceInfo =
465 new LLSDParcelVoiceInfoResponse("OpenSim Test", 1, creds);
466
467 // XXX for debugging purposes:
468 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
469 m_log.DebugFormat("[CAPS][PARCELVOICE]: {0}", r);
470
471 return r;
472 }
473 catch (Exception e)
474 {
475 m_log.Error("[CAPS]: " + e.ToString());
476 }
477
478 return null;
479 }
480
481 /// <summary>
482 /// Callback for a client request for Voice Account Details
483 /// </summary>
484 /// <param name="request"></param>
485 /// <param name="path"></param>
486 /// <param name="param"></param>
487 /// <returns></returns>
488 public string ProvisionVoiceAccountRequest(string request, string path, string param) {
489 try
490 {
491 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param);
492
493 if (null == CAPSGetUserDetails) throw new Exception("CAPSGetUserDetails null");
494
495 string voiceUser = "x" + Convert.ToBase64String(m_agentID.GetBytes());
496 voiceUser = voiceUser.Replace('+', '-').Replace('/', '_');
497
498 CachedUserInfo userInfo = CAPSGetUserDetails(m_agentID);
499 if (null == userInfo) throw new Exception("CAPSGetUserDetails returned null");
500
501 LLSDVoiceAccountResponse voiceAccountResponse =
502 new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.passwordHash);
503 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
504 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r);
505 return r;
506 }
507 catch (Exception e)
508 {
509 m_log.Error("[CAPS][PROVISIONVOICE]: " + e.ToString());
510 }
511
512 return null;
513 }
514
515 /// <summary> 422 /// <summary>
516 /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. 423 /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset.
517 /// </summary> 424 /// </summary>