aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Capabilities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs125
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs (renamed from OpenSim/Region/Capabilities/LLSDUploadReply.cs)4
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs21
-rw-r--r--OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs18
4 files changed, 87 insertions, 81 deletions
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
index 6373f6e..7216691 100644
--- a/OpenSim/Region/Capabilities/Caps.cs
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -48,8 +48,8 @@ namespace OpenSim.Region.Capabilities
48 private string m_requestPath = "0000/"; 48 private string m_requestPath = "0000/";
49 private string m_mapLayerPath = "0001/"; 49 private string m_mapLayerPath = "0001/";
50 private string m_newInventory = "0002/"; 50 private string m_newInventory = "0002/";
51 private string m_requestTexture = "0003/"; 51 // private string m_requestTexture = "0003/";
52 private string eventQueue = "0100/"; 52 //private string eventQueue = "0100/";
53 private BaseHttpServer httpListener; 53 private BaseHttpServer httpListener;
54 private LLUUID agentID; 54 private LLUUID agentID;
55 private AssetCache assetCache; 55 private AssetCache assetCache;
@@ -74,17 +74,12 @@ namespace OpenSim.Region.Capabilities
74 Console.WriteLine("registering CAPS handlers"); 74 Console.WriteLine("registering CAPS handlers");
75 string capsBase = "/CAPS/" + m_capsObjectPath; 75 string capsBase = "/CAPS/" + m_capsObjectPath;
76 76
77 77 httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
78 AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); 78 httpListener.AddStreamHandler( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest));
79
80 // httpListener.AddStreamHandler(
81 // new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer ));
82 79
83 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); 80 AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
84 AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); 81 // AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue);
85 AddLegacyCapsHandler( httpListener, eventQueue, ProcessEventQueue); 82 // AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture);
86 AddLegacyCapsHandler( httpListener, m_requestTexture, RequestTexture);
87
88 } 83 }
89 84
90 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] 85 [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
@@ -103,9 +98,7 @@ namespace OpenSim.Region.Capabilities
103 /// <returns></returns> 98 /// <returns></returns>
104 public string CapsRequest(string request, string path, string param) 99 public string CapsRequest(string request, string path, string param)
105 { 100 {
106 // Console.WriteLine("Caps Request " + request); 101 string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
107 string result = "";
108 result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities());
109 return result; 102 return result;
110 } 103 }
111 104
@@ -117,55 +110,33 @@ namespace OpenSim.Region.Capabilities
117 { 110 {
118 LLSDCapsDetails caps = new LLSDCapsDetails(); 111 LLSDCapsDetails caps = new LLSDCapsDetails();
119 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; 112 string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
120
121 caps.MapLayer = capsBaseUrl + m_mapLayerPath; 113 caps.MapLayer = capsBaseUrl + m_mapLayerPath;
122 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; 114 caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
123
124 return caps; 115 return caps;
125 } 116 }
126 117
127 /// <summary> 118 /// <summary>
128 /// 119 ///
129 /// </summary> 120 /// </summary>
130 /// <param name="request"></param> 121 /// <param name="mapReq"></param>
131 /// <param name="path"></param>
132 /// <param name="param"></param>
133 /// <returns></returns> 122 /// <returns></returns>
134 public string MapLayer(string request, string path, string param)
135 {
136 Console.WriteLine("map request: " + request);
137 Encoding _enc = Encoding.UTF8;
138 Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(_enc.GetBytes(request));
139 LLSDMapRequest mapReq = new LLSDMapRequest();
140 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq);
141
142 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
143 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse());
144 string res = LLSDHelpers.SerialiseLLSDReply(mapResponse);
145
146 return res;
147 }
148
149 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) 123 public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
150 { 124 {
151 Console.WriteLine("Map request " + mapReq.Flags);
152 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); 125 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
153 mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); 126 mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse());
154 return mapResponse; 127 return mapResponse;
155 } 128 }
156 129
157
158 /// <summary> 130 /// <summary>
159 /// 131 ///
160 /// </summary> 132 /// </summary>
161 /// <returns></returns> 133 /// <returns></returns>
162 protected LLSDMapLayer BuildLLSDMapLayerResponse() 134 protected LLSDMapLayer GetLLSDMapLayerResponse()
163 { 135 {
164 LLSDMapLayer mapLayer = new LLSDMapLayer(); 136 LLSDMapLayer mapLayer = new LLSDMapLayer();
165 mapLayer.Right = 5000; 137 mapLayer.Right = 5000;
166 mapLayer.Top = 5000; 138 mapLayer.Top = 5000;
167 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); 139 mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006");
168
169 return mapLayer; 140 return mapLayer;
170 } 141 }
171 142
@@ -182,6 +153,7 @@ namespace OpenSim.Region.Capabilities
182 return ""; 153 return "";
183 } 154 }
184 155
156 #region EventQueue (Currently not enabled)
185 /// <summary> 157 /// <summary>
186 /// 158 ///
187 /// </summary> 159 /// </summary>
@@ -240,36 +212,29 @@ namespace OpenSim.Region.Capabilities
240 eventQueueCount++; 212 eventQueueCount++;
241 return res; 213 return res;
242 } 214 }
243 215 #endregion
216
244 /// <summary> 217 /// <summary>
245 /// 218 ///
246 /// </summary> 219 /// </summary>
247 /// <param name="request"></param> 220 /// <param name="llsdRequest"></param>
248 /// <param name="path"></param>
249 /// <param name="param"></param>
250 /// <returns></returns> 221 /// <returns></returns>
251 public string NewAgentInventory(string request, string path, string param) 222 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
252 { 223 {
253 //Console.WriteLine("received upload request:"+ request); 224 string capsBase = "/CAPS/" + m_capsObjectPath;
254 string res = "";
255 LLUUID newAsset = LLUUID.Random(); 225 LLUUID newAsset = LLUUID.Random();
256 LLUUID newInvItem = LLUUID.Random(); 226 LLUUID newInvItem = LLUUID.Random();
257 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 227 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
258 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener);
259 228
260 string capsBase = "/CAPS/" + m_capsObjectPath; 229 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, capsBase + uploaderPath, this.httpListener);
261 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); 230 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
262 231 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
263 232
264 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath +uploaderPath; 233 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
265 //Console.WriteLine("uploader url is " + uploaderURL); 234 uploadResponse.uploader = uploaderURL;
266 res += "<llsd><map>"; 235 uploadResponse.state = "upload";
267 res += "<key>uploader</key><string>" + uploaderURL + "</string>"; 236 uploader.OnUpLoad += this.UploadCompleteHandler;
268 //res += "<key>success</key><boolean>true</boolean>"; 237 return uploadResponse;
269 res += "<key>state</key><string>upload</string>";
270 res += "</map></llsd>";
271 uploader.OnUpLoad += this.UploadHandler;
272 return res;
273 } 238 }
274 239
275 /// <summary> 240 /// <summary>
@@ -278,9 +243,8 @@ namespace OpenSim.Region.Capabilities
278 /// <param name="assetID"></param> 243 /// <param name="assetID"></param>
279 /// <param name="inventoryItem"></param> 244 /// <param name="inventoryItem"></param>
280 /// <param name="data"></param> 245 /// <param name="data"></param>
281 public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) 246 public void UploadCompleteHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data)
282 { 247 {
283 // Console.WriteLine("upload handler called");
284 AssetBase asset; 248 AssetBase asset;
285 asset = new AssetBase(); 249 asset = new AssetBase();
286 asset.FullID = assetID; 250 asset.FullID = assetID;
@@ -299,42 +263,45 @@ namespace OpenSim.Region.Capabilities
299 private LLUUID newAssetID; 263 private LLUUID newAssetID;
300 private LLUUID inventoryItemID; 264 private LLUUID inventoryItemID;
301 private BaseHttpServer httpListener; 265 private BaseHttpServer httpListener;
266
267 /// <summary>
268 ///
269 /// </summary>
270 /// <param name="assetID"></param>
271 /// <param name="inventoryItem"></param>
272 /// <param name="path"></param>
273 /// <param name="httpServer"></param>
302 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) 274 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer)
303 { 275 {
304 newAssetID = assetID; 276 newAssetID = assetID;
305 inventoryItemID = inventoryItem; 277 inventoryItemID = inventoryItem;
306 uploaderPath = path; 278 uploaderPath = path;
307 httpListener = httpServer; 279 httpListener = httpServer;
308
309 } 280 }
310 281
282 /// <summary>
283 ///
284 /// </summary>
285 /// <param name="data"></param>
286 /// <param name="path"></param>
287 /// <param name="param"></param>
288 /// <returns></returns>
311 public string uploaderCaps(byte[] data, string path, string param) 289 public string uploaderCaps(byte[] data, string path, string param)
312 { 290 {
313 //Encoding _enc = Encoding.UTF8;
314 //byte[] data = _enc.GetBytes(request);
315 //Console.WriteLine("recieved upload " + Util.FieldToString(data));
316 LLUUID inv = this.inventoryItemID; 291 LLUUID inv = this.inventoryItemID;
317 string res = ""; 292 string res = "";
318 res += "<llsd><map>"; 293 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
319 res += "<key>new_asset</key><string>" + newAssetID.ToStringHyphenated() + "</string>"; 294 uploadComplete.new_asset = newAssetID.ToStringHyphenated();
320 res += "<key>new_inventory_item</key><uuid>" + inv.ToStringHyphenated() + "</uuid>"; 295 uploadComplete.new_inventory_item = inv;
321 res += "<key>state</key><string>complete</string>"; 296 uploadComplete.state = "complete";
322 res += "</map></llsd>"; 297 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
323 298
324 // Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated()); 299 httpListener.RemoveStreamHandler("POST", uploaderPath);
325 httpListener.RemoveStreamHandler("POST", "/CAPS/" + uploaderPath);
326 300
327 if (OnUpLoad != null) 301 if (OnUpLoad != null)
328 { 302 {
329 OnUpLoad(newAssetID, inv, data); 303 OnUpLoad(newAssetID, inv, data);
330 } 304 }
331
332 /*
333 FileStream fs = File.Create("upload.jp2");
334 BinaryWriter bw = new BinaryWriter(fs);
335 bw.Write(data);
336 bw.Close();
337 fs.Close();*/
338 return res; 305 return res;
339 } 306 }
340 } 307 }
diff --git a/OpenSim/Region/Capabilities/LLSDUploadReply.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs
index 023a056..1b78353 100644
--- a/OpenSim/Region/Capabilities/LLSDUploadReply.cs
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs
@@ -30,13 +30,13 @@ using libsecondlife;
30namespace OpenSim.Region.Capabilities 30namespace OpenSim.Region.Capabilities
31{ 31{
32 [LLSDType("MAP")] 32 [LLSDType("MAP")]
33 public class LLSDUploadReply 33 public class LLSDAssetUploadComplete
34 { 34 {
35 public string new_asset = ""; 35 public string new_asset = "";
36 public LLUUID new_inventory_item = LLUUID.Zero; 36 public LLUUID new_inventory_item = LLUUID.Zero;
37 public string state = ""; 37 public string state = "";
38 38
39 public LLSDUploadReply() 39 public LLSDAssetUploadComplete()
40 { 40 {
41 41
42 } 42 }
diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs
new file mode 100644
index 0000000..7ef77cb
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs
@@ -0,0 +1,21 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Region.Capabilities
7{
8 [LLSDMap]
9 public class LLSDAssetUploadRequest
10 {
11 public string asset_type = "";
12 public string description = "";
13 public LLUUID folder_id = LLUUID.Zero;
14 public string inventory_type = "";
15 public string name = "";
16
17 public LLSDAssetUploadRequest()
18 {
19 }
20 }
21}
diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs
new file mode 100644
index 0000000..1a620ae
--- /dev/null
+++ b/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Capabilities
6{
7 [LLSDMap]
8 public class LLSDAssetUploadResponse
9 {
10 public string uploader = "";
11 public string state = "";
12
13 public LLSDAssetUploadResponse()
14 {
15
16 }
17 }
18}