diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/AgentAssetUpload.cs | 19 | ||||
-rw-r--r-- | OpenSim.RegionServer/Assets/InventoryCache.cs | 10 | ||||
-rw-r--r-- | OpenSim.RegionServer/CAPS/SimHttp.cs | 166 | ||||
-rw-r--r-- | OpenSim.RegionServer/SimClient.cs | 18 |
4 files changed, 201 insertions, 12 deletions
diff --git a/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim.RegionServer/AgentAssetUpload.cs index 5d40c88..a482e80 100644 --- a/OpenSim.RegionServer/AgentAssetUpload.cs +++ b/OpenSim.RegionServer/AgentAssetUpload.cs | |||
@@ -79,7 +79,6 @@ namespace OpenSim | |||
79 | 79 | ||
80 | 80 | ||
81 | } | 81 | } |
82 | /* for now we will only support uploading of textures | ||
83 | else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5) | 82 | else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5) |
84 | { | 83 | { |
85 | 84 | ||
@@ -92,7 +91,7 @@ namespace OpenSim | |||
92 | asset.Data = pack.AssetBlock.AssetData; | 91 | asset.Data = pack.AssetBlock.AssetData; |
93 | 92 | ||
94 | 93 | ||
95 | }*/ | 94 | } |
96 | 95 | ||
97 | if (asset != null) | 96 | if (asset != null) |
98 | { | 97 | { |
@@ -169,6 +168,22 @@ namespace OpenSim | |||
169 | 168 | ||
170 | #endregion | 169 | #endregion |
171 | 170 | ||
171 | public AssetBase AddUploadToAssetCache(LLUUID transactionID) | ||
172 | { | ||
173 | AssetBase asset = null; | ||
174 | if(this.transactions.ContainsKey(transactionID)) | ||
175 | { | ||
176 | AssetTransaction trans = this.transactions[transactionID]; | ||
177 | if (trans.UploadComplete) | ||
178 | { | ||
179 | OpenSimRoot.Instance.AssetCache.AddAsset(trans.Asset); | ||
180 | asset = trans.Asset; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | return asset; | ||
185 | } | ||
186 | |||
172 | public void CreateInventoryItem(CreateInventoryItemPacket packet) | 187 | public void CreateInventoryItem(CreateInventoryItemPacket packet) |
173 | { | 188 | { |
174 | if(this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) | 189 | if(this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) |
diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs index f50047a..3a4aa36 100644 --- a/OpenSim.RegionServer/Assets/InventoryCache.cs +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs | |||
@@ -57,6 +57,16 @@ namespace OpenSim.Assets | |||
57 | this._agentsInventory.Add(agentInventory.AgentID, agentInventory); | 57 | this._agentsInventory.Add(agentInventory.AgentID, agentInventory); |
58 | } | 58 | } |
59 | 59 | ||
60 | public AgentInventory GetAgentsInventory(LLUUID agentID) | ||
61 | { | ||
62 | if (this._agentsInventory.ContainsKey(agentID)) | ||
63 | { | ||
64 | return this._agentsInventory[agentID]; | ||
65 | } | ||
66 | |||
67 | return null; | ||
68 | } | ||
69 | |||
60 | public void ClientLeaving(LLUUID clientID) | 70 | public void ClientLeaving(LLUUID clientID) |
61 | { | 71 | { |
62 | if (this._agentsInventory.ContainsKey(clientID)) | 72 | if (this._agentsInventory.ContainsKey(clientID)) |
diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs index f5a8705..77c6bb8 100644 --- a/OpenSim.RegionServer/CAPS/SimHttp.cs +++ b/OpenSim.RegionServer/CAPS/SimHttp.cs | |||
@@ -48,12 +48,17 @@ namespace OpenSim.CAPS | |||
48 | { | 48 | { |
49 | public Thread HTTPD; | 49 | public Thread HTTPD; |
50 | public HttpListener Listener; | 50 | public HttpListener Listener; |
51 | private string AdminPage; | ||
52 | private string NewAccountForm; | ||
53 | private string LoginForm; | ||
54 | private string passWord = "Admin"; | ||
51 | 55 | ||
52 | public SimCAPSHTTPServer() | 56 | public SimCAPSHTTPServer() |
53 | { | 57 | { |
54 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); | 58 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); |
55 | HTTPD = new Thread(new ThreadStart(StartHTTP)); | 59 | HTTPD = new Thread(new ThreadStart(StartHTTP)); |
56 | HTTPD.Start(); | 60 | HTTPD.Start(); |
61 | LoadAdminPage(); | ||
57 | } | 62 | } |
58 | 63 | ||
59 | public void StartHTTP() | 64 | public void StartHTTP() |
@@ -79,7 +84,7 @@ namespace OpenSim.CAPS | |||
79 | } | 84 | } |
80 | } | 85 | } |
81 | 86 | ||
82 | static string ParseXMLRPC(string requestBody) | 87 | private string ParseXMLRPC(string requestBody) |
83 | { | 88 | { |
84 | try | 89 | try |
85 | { | 90 | { |
@@ -111,19 +116,101 @@ namespace OpenSim.CAPS | |||
111 | return ""; | 116 | return ""; |
112 | } | 117 | } |
113 | 118 | ||
114 | static string ParseREST(string requestBody, string requestURL) | 119 | private string ParseREST(string requestBody, string requestURL, string requestMethod) |
115 | { | 120 | { |
116 | return ""; | 121 | string responseString = ""; |
122 | switch (requestURL) | ||
123 | { | ||
124 | case "/Admin/Accounts": | ||
125 | if (requestMethod == "GET") | ||
126 | { | ||
127 | responseString = "<p> Account management </p>"; | ||
128 | responseString += "<br> "; | ||
129 | responseString += "<p> Create New Account </p>"; | ||
130 | responseString += NewAccountForm; | ||
131 | } | ||
132 | break; | ||
133 | case "/Admin/Clients": | ||
134 | if (requestMethod == "GET") | ||
135 | { | ||
136 | responseString = " <p> Listing connected Clients </p>" ; | ||
137 | OpenSim.world.Avatar TempAv; | ||
138 | foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys) | ||
139 | { | ||
140 | if (OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") | ||
141 | { | ||
142 | TempAv = (OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID]; | ||
143 | responseString += "<p>"; | ||
144 | responseString += String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()); | ||
145 | responseString += "</p>"; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | break; | ||
150 | case "/Admin/NewAccount": | ||
151 | if (requestMethod == "POST") | ||
152 | { | ||
153 | string[] comp = new string[10]; | ||
154 | string[] passw = new string[3]; | ||
155 | string delimStr = "&"; | ||
156 | char[] delimiter = delimStr.ToCharArray(); | ||
157 | string delimStr2 = "="; | ||
158 | char[] delimiter2 = delimStr2.ToCharArray(); | ||
159 | |||
160 | //Console.WriteLine(requestBody); | ||
161 | comp = requestBody.Split(delimiter); | ||
162 | passw = comp[3].Split(delimiter2); | ||
163 | if (passw[1] == passWord) | ||
164 | { | ||
165 | responseString = "<p> New Account created </p>"; | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | responseString = "<p> Admin password is incorrect, please login with the correct password</p>"; | ||
170 | responseString += "<br><br>" + LoginForm; | ||
171 | } | ||
172 | |||
173 | |||
174 | } | ||
175 | break; | ||
176 | case "/Admin/Login": | ||
177 | if (requestMethod == "POST") | ||
178 | { | ||
179 | Console.WriteLine(requestBody); | ||
180 | if (requestBody == passWord) | ||
181 | { | ||
182 | responseString = "<p> Login Successful </p>"; | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | responseString = "<p> PassWord Error </p>"; | ||
187 | responseString += "<p> Please Login with the correct password </p>"; | ||
188 | responseString += "<br><br> " + LoginForm; | ||
189 | } | ||
190 | } | ||
191 | break; | ||
192 | case "/Admin/Welcome": | ||
193 | if (requestMethod == "GET") | ||
194 | { | ||
195 | responseString = "Welcome to the OpenSim Admin Page"; | ||
196 | responseString += "<br><br><br> " + LoginForm; | ||
197 | |||
198 | } | ||
199 | break; | ||
200 | } | ||
201 | |||
202 | return responseString; | ||
117 | } | 203 | } |
118 | 204 | ||
119 | static string ParseLLSDXML(string requestBody) | 205 | private string ParseLLSDXML(string requestBody) |
120 | { | 206 | { |
121 | // dummy function for now - IMPLEMENT ME! | 207 | // dummy function for now - IMPLEMENT ME! |
122 | return ""; | 208 | return ""; |
123 | } | 209 | } |
124 | 210 | ||
125 | static void HandleRequest(Object stateinfo) | 211 | public void HandleRequest(Object stateinfo) |
126 | { | 212 | { |
213 | // Console.WriteLine("new http incoming"); | ||
127 | HttpListenerContext context = (HttpListenerContext)stateinfo; | 214 | HttpListenerContext context = (HttpListenerContext)stateinfo; |
128 | 215 | ||
129 | HttpListenerRequest request = context.Request; | 216 | HttpListenerRequest request = context.Request; |
@@ -140,6 +227,9 @@ namespace OpenSim.CAPS | |||
140 | body.Close(); | 227 | body.Close(); |
141 | reader.Close(); | 228 | reader.Close(); |
142 | 229 | ||
230 | //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType); | ||
231 | //Console.WriteLine(requestBody); | ||
232 | |||
143 | string responseString = ""; | 233 | string responseString = ""; |
144 | switch (request.ContentType) | 234 | switch (request.ContentType) |
145 | { | 235 | { |
@@ -156,10 +246,26 @@ namespace OpenSim.CAPS | |||
156 | response.AddHeader("Content-type", "application/xml"); | 246 | response.AddHeader("Content-type", "application/xml"); |
157 | break; | 247 | break; |
158 | 248 | ||
249 | case "application/x-www-form-urlencoded": | ||
250 | // a form data POST so send to the REST parser | ||
251 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
252 | response.AddHeader("Content-type", "text/html"); | ||
253 | break; | ||
254 | |||
159 | case null: | 255 | case null: |
160 | // must be REST or invalid crap, so pass to the REST parser | 256 | if ((request.HttpMethod == "GET") && (request.RawUrl == "/Admin")) |
161 | responseString = ParseREST(request.Url.OriginalString, requestBody); | 257 | { |
258 | responseString = AdminPage; | ||
259 | response.AddHeader("Content-type", "text/html"); | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | // must be REST or invalid crap, so pass to the REST parser | ||
264 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
265 | response.AddHeader("Content-type", "text/html"); | ||
266 | } | ||
162 | break; | 267 | break; |
268 | |||
163 | } | 269 | } |
164 | 270 | ||
165 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); | 271 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); |
@@ -169,6 +275,52 @@ namespace OpenSim.CAPS | |||
169 | output.Write(buffer, 0, buffer.Length); | 275 | output.Write(buffer, 0, buffer.Length); |
170 | output.Close(); | 276 | output.Close(); |
171 | } | 277 | } |
278 | |||
279 | private void LoadAdminPage() | ||
280 | { | ||
281 | try | ||
282 | { | ||
283 | StreamReader SR; | ||
284 | string lines; | ||
285 | AdminPage = ""; | ||
286 | NewAccountForm = ""; | ||
287 | LoginForm = ""; | ||
288 | SR = File.OpenText("testadmin.htm"); | ||
289 | |||
290 | while (!SR.EndOfStream) | ||
291 | { | ||
292 | lines = SR.ReadLine(); | ||
293 | AdminPage += lines + "\n"; | ||
294 | |||
295 | } | ||
296 | SR.Close(); | ||
297 | |||
298 | SR = File.OpenText("newaccountform.htm"); | ||
299 | |||
300 | while (!SR.EndOfStream) | ||
301 | { | ||
302 | lines = SR.ReadLine(); | ||
303 | NewAccountForm += lines + "\n"; | ||
304 | |||
305 | } | ||
306 | SR.Close(); | ||
307 | |||
308 | SR = File.OpenText("login.htm"); | ||
309 | |||
310 | while (!SR.EndOfStream) | ||
311 | { | ||
312 | lines = SR.ReadLine(); | ||
313 | LoginForm += lines + "\n"; | ||
314 | |||
315 | } | ||
316 | SR.Close(); | ||
317 | } | ||
318 | catch (Exception e) | ||
319 | { | ||
320 | Console.WriteLine(e.ToString()); | ||
321 | } | ||
322 | |||
323 | } | ||
172 | } | 324 | } |
173 | 325 | ||
174 | 326 | ||
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index dea385c..811e8b8 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs | |||
@@ -287,7 +287,7 @@ namespace OpenSim | |||
287 | //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random()); | 287 | //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random()); |
288 | //} | 288 | //} |
289 | //else | 289 | //else |
290 | //{*/ | 290 | //{ |
291 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | 291 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); |
292 | //} | 292 | //} |
293 | break; | 293 | break; |
@@ -318,13 +318,25 @@ namespace OpenSim | |||
318 | OpenSimRoot.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch); | 318 | OpenSimRoot.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch); |
319 | break; | 319 | break; |
320 | case PacketType.UpdateInventoryItem: | 320 | case PacketType.UpdateInventoryItem: |
321 | /* UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; | 321 | /* |
322 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; | ||
322 | for (int i = 0; i < update.InventoryData.Length; i++) | 323 | for (int i = 0; i < update.InventoryData.Length; i++) |
323 | { | 324 | { |
324 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | 325 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) |
325 | { | 326 | { |
326 | AssetBase asset = OpenSimRoot.Instance.AssetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | 327 | AssetBase asset = OpenSimRoot.Instance.AssetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); |
327 | OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset); | 328 | if (asset != null) |
329 | { | ||
330 | OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset); | ||
331 | } | ||
332 | else | ||
333 | { | ||
334 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | ||
335 | if (asset != null) | ||
336 | { | ||
337 | OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset); | ||
338 | } | ||
339 | } | ||
328 | } | 340 | } |
329 | }*/ | 341 | }*/ |
330 | break; | 342 | break; |