diff options
author | MW | 2007-06-24 15:24:02 +0000 |
---|---|---|
committer | MW | 2007-06-24 15:24:02 +0000 |
commit | 38a800400ae8c61eef0770b8c49aa6e637478e58 (patch) | |
tree | 2d53e3c67a0990bf199e8594240cdee8dc1a8494 /OpenSim/OpenSim.Region/Caps.cs | |
parent | More work on CAPS handler. (diff) | |
download | opensim-SC_OLD-38a800400ae8c61eef0770b8c49aa6e637478e58.zip opensim-SC_OLD-38a800400ae8c61eef0770b8c49aa6e637478e58.tar.gz opensim-SC_OLD-38a800400ae8c61eef0770b8c49aa6e637478e58.tar.bz2 opensim-SC_OLD-38a800400ae8c61eef0770b8c49aa6e637478e58.tar.xz |
Disabled the CheckSum Server as it seems that isn't used by viewer 1.18.
Started to add support for asset uploads over CAPS (the asset is uploaded but seems to come out corrupt).
Started to cleanup/rewrite the AssetCache.
Fixed bug in MapBlock requests, where data for some regions wasn't being sent.
Renamed PrimData's Texture to TextureEntry.
most likely a few other small changes.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/OpenSim.Region/Caps.cs | 116 |
1 files changed, 104 insertions, 12 deletions
diff --git a/OpenSim/OpenSim.Region/Caps.cs b/OpenSim/OpenSim.Region/Caps.cs index c86061f..5be481e 100644 --- a/OpenSim/OpenSim.Region/Caps.cs +++ b/OpenSim/OpenSim.Region/Caps.cs | |||
@@ -1,23 +1,34 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | ||
4 | using OpenSim.Servers; | 5 | using OpenSim.Servers; |
6 | using OpenSim.Framework.Utilities; | ||
7 | using OpenSim.Framework.Types; | ||
8 | using OpenSim.Caches; | ||
5 | using libsecondlife; | 9 | using libsecondlife; |
6 | 10 | ||
7 | namespace OpenSim.Region | 11 | namespace OpenSim.Region |
8 | { | 12 | { |
13 | public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data); | ||
14 | |||
9 | public class Caps | 15 | public class Caps |
10 | { | 16 | { |
17 | |||
11 | private string httpListenerAddress; | 18 | private string httpListenerAddress; |
12 | private uint httpListenPort; | 19 | private uint httpListenPort; |
13 | private string capsObjectPath = "00001-"; | 20 | private string capsObjectPath = "00001-"; |
14 | private string requestPath = "0000/"; | 21 | private string requestPath = "0000/"; |
15 | private string mapLayerPath = "0001/"; | 22 | private string mapLayerPath = "0001/"; |
23 | private string newInventory = "0002/"; | ||
24 | private string requestTexture = "0003/"; | ||
16 | private BaseHttpServer httpListener; | 25 | private BaseHttpServer httpListener; |
17 | private LLUUID agentID; | 26 | private LLUUID agentID; |
27 | private AssetCache assetCache; | ||
18 | 28 | ||
19 | public Caps(BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) | 29 | public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) |
20 | { | 30 | { |
31 | assetCache = assetCach; | ||
21 | capsObjectPath = capsPath; | 32 | capsObjectPath = capsPath; |
22 | httpListener = httpServer; | 33 | httpListener = httpServer; |
23 | httpListenerAddress = httpListen; | 34 | httpListenerAddress = httpListen; |
@@ -31,8 +42,9 @@ namespace OpenSim.Region | |||
31 | public void RegisterHandlers() | 42 | public void RegisterHandlers() |
32 | { | 43 | { |
33 | Console.WriteLine("registering CAPS handlers"); | 44 | Console.WriteLine("registering CAPS handlers"); |
34 | httpListener.AddRestHandler("POST", "/CAPS/" +capsObjectPath+ requestPath, CapsRequest); | 45 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + requestPath, CapsRequest); |
35 | httpListener.AddRestHandler("POST", "/CAPS/" +capsObjectPath+ mapLayerPath, MapLayer); | 46 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + mapLayerPath, MapLayer); |
47 | httpListener.AddRestHandler("POST", "/CAPS/" + capsObjectPath + newInventory, NewAgentInventory); | ||
36 | } | 48 | } |
37 | 49 | ||
38 | /// <summary> | 50 | /// <summary> |
@@ -44,7 +56,7 @@ namespace OpenSim.Region | |||
44 | /// <returns></returns> | 56 | /// <returns></returns> |
45 | public string CapsRequest(string request, string path, string param) | 57 | public string CapsRequest(string request, string path, string param) |
46 | { | 58 | { |
47 | //Console.WriteLine("Caps Request " + request); | 59 | Console.WriteLine("Caps Request " + request); |
48 | string result = "<llsd><map>"; | 60 | string result = "<llsd><map>"; |
49 | result += this.GetCapabilities(); | 61 | result += this.GetCapabilities(); |
50 | result += "</map></llsd>"; | 62 | result += "</map></llsd>"; |
@@ -57,10 +69,11 @@ namespace OpenSim.Region | |||
57 | /// <returns></returns> | 69 | /// <returns></returns> |
58 | protected string GetCapabilities() | 70 | protected string GetCapabilities() |
59 | { | 71 | { |
60 | string capURLS=""; | 72 | string capURLS = ""; |
61 | 73 | ||
62 | capURLS += "<key>MapLayer</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" +capsObjectPath+ mapLayerPath + "</string>"; | 74 | capURLS += "<key>MapLayer</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + "</string>"; |
63 | 75 | capURLS += "<key>NewFileAgentInventory</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + "</string>"; | |
76 | //capURLS += "<key>RequestTextureDownload</key><string>http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + "</string>"; | ||
64 | return capURLS; | 77 | return capURLS; |
65 | } | 78 | } |
66 | 79 | ||
@@ -93,15 +106,94 @@ namespace OpenSim.Region | |||
93 | int bottom; | 106 | int bottom; |
94 | LLUUID image = null; | 107 | LLUUID image = null; |
95 | 108 | ||
96 | left = 500; | 109 | left = 0; |
97 | bottom = 500; | 110 | bottom = 0; |
98 | top = 1500; | 111 | top = 5000; |
99 | right = 1500; | 112 | right = 5000; |
100 | image = new LLUUID("00000000-0000-0000-9999-000000000006"); | 113 | image = new LLUUID("00000000-0000-0000-9999-000000000006"); |
101 | 114 | ||
102 | res += "<map><key>Left</key><integer>" + left + "</integer><key>Bottom</key><integer>" + bottom + "</integer><key>Top</key><integer>" + top + "</integer><key>Right</key><integer>" + right + "</integer><key>ImageID</key><uuid>" + image.ToStringHyphenated() + "</uuid></map>"; | 115 | res += "<map><key>Left</key><integer>" + left + "</integer><key>Bottom</key><integer>" + bottom + "</integer><key>Top</key><integer>" + top + "</integer><key>Right</key><integer>" + right + "</integer><key>ImageID</key><uuid>" + image.ToStringHyphenated() + "</uuid></map>"; |
103 | 116 | ||
117 | return res; | ||
118 | } | ||
119 | |||
120 | public string NewAgentInventory(string request, string path, string param) | ||
121 | { | ||
122 | |||
123 | //Console.WriteLine("received upload request:"+ request); | ||
124 | string res = ""; | ||
125 | LLUUID newAsset = LLUUID.Random(); | ||
126 | string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 7000).ToString("0000"); | ||
127 | AssetUploader uploader = new AssetUploader(newAsset, uploaderPath, this.httpListener); | ||
128 | httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); | ||
129 | string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; | ||
130 | Console.WriteLine("uploader url is " + uploaderURL); | ||
131 | res += "<llsd><map>"; | ||
132 | res += "<key>uploader</key><string>"+uploaderURL +"</string>"; | ||
133 | //res += "<key>success</key><boolean>true</boolean>"; | ||
134 | res += "<key>state</key><string>upload</string>"; | ||
135 | res += "</map></llsd>"; | ||
136 | uploader.OnUpLoad += this.UploadHandler; | ||
104 | return res; | 137 | return res; |
105 | } | 138 | } |
139 | |||
140 | public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) | ||
141 | { | ||
142 | // Console.WriteLine("upload handler called"); | ||
143 | AssetBase asset; | ||
144 | asset = new AssetBase(); | ||
145 | asset.FullID = assetID; | ||
146 | asset.Type = 0; | ||
147 | asset.InvType = 0; | ||
148 | asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); | ||
149 | asset.Data = data; | ||
150 | this.assetCache.AddAsset(asset); | ||
151 | |||
152 | } | ||
153 | |||
154 | public class AssetUploader | ||
155 | { | ||
156 | public event UpLoadedTexture OnUpLoad; | ||
157 | |||
158 | private string uploaderPath = ""; | ||
159 | private LLUUID newAssetID; | ||
160 | //private LLUUID inventoryItemID; | ||
161 | private BaseHttpServer httpListener; | ||
162 | public AssetUploader(LLUUID assetID, string path,BaseHttpServer httpServer) | ||
163 | { | ||
164 | newAssetID = assetID; | ||
165 | uploaderPath = path; | ||
166 | httpListener = httpServer; | ||
167 | |||
168 | } | ||
169 | |||
170 | public string uploaderCaps(string request, string path, string param) | ||
171 | { | ||
172 | Encoding _enc = System.Text.Encoding.UTF8; | ||
173 | byte[] data = _enc.GetBytes(request); | ||
174 | //Console.WriteLine("recieved upload " + Util.FieldToString(data)); | ||
175 | LLUUID inv = LLUUID.Random(); | ||
176 | string res = ""; | ||
177 | res += "<llsd><map>"; | ||
178 | res += "<key>new_asset</key><string>" + newAssetID.ToStringHyphenated() + "</string>"; | ||
179 | res += "<key>new_inventory_item</key><uuid>" + inv.ToStringHyphenated() + "</uuid>"; | ||
180 | res += "<key>state</key><string>complete</string>"; | ||
181 | res += "</map></llsd>"; | ||
182 | |||
183 | Console.WriteLine("asset " + newAssetID.ToStringHyphenated() + " , inventory item " + inv.ToStringHyphenated()); | ||
184 | httpListener.RemoveRestHandler("POST", "/CAPS/"+uploaderPath); | ||
185 | if (OnUpLoad != null) | ||
186 | { | ||
187 | OnUpLoad(newAssetID, inv, data); | ||
188 | } | ||
189 | |||
190 | /*FileStream fs = File.Create("upload.jp2"); | ||
191 | BinaryWriter bw = new BinaryWriter(fs); | ||
192 | bw.Write(data); | ||
193 | bw.Close(); | ||
194 | fs.Close();*/ | ||
195 | return res; | ||
196 | } | ||
197 | } | ||
106 | } | 198 | } |
107 | } | 199 | } |