aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs507
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs12
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs180
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs114
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs131
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs30
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs30
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs212
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs8
12 files changed, 855 insertions, 391 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 74b980c..6f8d9ed 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
@@ -122,7 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
122 m_Enabled = true; 123 m_Enabled = true;
123 } 124 }
124 125
125 #region IAssetService 126#region IAssetService
126 127
127 public AssetBase Get(string id) 128 public AssetBase Get(string id)
128 { 129 {
@@ -140,8 +141,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
140 return asset; 141 return asset;
141 } 142 }
142 143
143 return GetRemote(id); 144 return SimianGetOperation(id);
144 } 145 }
146
145 147
146 public AssetBase GetCached(string id) 148 public AssetBase GetCached(string id)
147 { 149 {
@@ -164,8 +166,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
164 throw new InvalidOperationException(); 166 throw new InvalidOperationException();
165 } 167 }
166 168
167 AssetMetadata metadata = null;
168
169 // Cache fetch 169 // Cache fetch
170 if (m_cache != null) 170 if (m_cache != null)
171 { 171 {
@@ -174,50 +174,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
174 return asset.Metadata; 174 return asset.Metadata;
175 } 175 }
176 176
177 Uri url; 177 // return GetRemoteMetadata(id);
178 178 return SimianGetMetadataOperation(id);
179 // Determine if id is an absolute URL or a grid-relative UUID
180 if (!Uri.TryCreate(id, UriKind.Absolute, out url))
181 url = new Uri(m_serverUrl + id);
182
183 try
184 {
185 HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
186 request.Method = "HEAD";
187
188 using (WebResponse response = request.GetResponse())
189 {
190 using (Stream responseStream = response.GetResponseStream())
191 {
192 // Create the metadata object
193 metadata = new AssetMetadata();
194 metadata.ContentType = response.ContentType;
195 metadata.ID = id;
196
197 UUID uuid;
198 if (UUID.TryParse(id, out uuid))
199 metadata.FullID = uuid;
200
201 string lastModifiedStr = response.Headers.Get("Last-Modified");
202 if (!String.IsNullOrEmpty(lastModifiedStr))
203 {
204 DateTime lastModified;
205 if (DateTime.TryParse(lastModifiedStr, out lastModified))
206 metadata.CreationDate = lastModified;
207 }
208 }
209 }
210 }
211 catch (Exception ex)
212 {
213 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
214 }
215
216 return metadata;
217 } 179 }
218 180
219 public byte[] GetData(string id) 181 public byte[] GetData(string id)
220 { 182 {
183 if (String.IsNullOrEmpty(m_serverUrl))
184 {
185 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
186 throw new InvalidOperationException();
187 }
188
221 AssetBase asset = Get(id); 189 AssetBase asset = Get(id);
222 190
223 if (asset != null) 191 if (asset != null)
@@ -255,7 +223,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
255 Util.FireAndForget( 223 Util.FireAndForget(
256 delegate(object o) 224 delegate(object o)
257 { 225 {
258 AssetBase asset = GetRemote(id); 226 AssetBase asset = SimianGetOperation(id);
259 handler(id, sender, asset); 227 handler(id, sender, asset);
260 } 228 }
261 ); 229 );
@@ -278,7 +246,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
278 } 246 }
279 247
280 bool storedInCache = false; 248 bool storedInCache = false;
281 string errorMessage = null;
282 249
283 // AssetID handling 250 // AssetID handling
284 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) 251 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID)
@@ -307,83 +274,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
307 return asset.ID; 274 return asset.ID;
308 } 275 }
309 276
310 // Distinguish public and private assets 277 return SimianStoreOperation(asset);
311 bool isPublic = true;
312 switch ((AssetType)asset.Type)
313 {
314 case AssetType.CallingCard:
315 case AssetType.Gesture:
316 case AssetType.LSLBytecode:
317 case AssetType.LSLText:
318 isPublic = false;
319 break;
320 }
321
322 // Make sure ContentType is set
323 if (String.IsNullOrEmpty(asset.Metadata.ContentType))
324 asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type);
325
326 // Build the remote storage request
327 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
328 {
329 new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
330 new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
331 new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
332 new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
333 new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
334 };
335
336 // Make the remote storage request
337 try
338 {
339 // Simian does not require the asset ID to be in the URL because it's in the post data.
340 // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
341 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
342
343 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
344 {
345 using (Stream responseStream = response.GetResponseStream())
346 {
347 string responseStr = null;
348
349 try
350 {
351 responseStr = responseStream.GetStreamString();
352 OSD responseOSD = OSDParser.Deserialize(responseStr);
353 if (responseOSD.Type == OSDType.Map)
354 {
355 OSDMap responseMap = (OSDMap)responseOSD;
356 if (responseMap["Success"].AsBoolean())
357 return asset.ID;
358 else
359 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
360 }
361 else
362 {
363 errorMessage = "Response format was invalid:\n" + responseStr;
364 }
365 }
366 catch (Exception ex)
367 {
368 if (!String.IsNullOrEmpty(responseStr))
369 errorMessage = "Failed to parse the response:\n" + responseStr;
370 else
371 errorMessage = "Failed to retrieve the response: " + ex.Message;
372 }
373 }
374 }
375 }
376 catch (WebException ex)
377 {
378 errorMessage = ex.Message;
379 }
380
381 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
382 asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
383
384 return null;
385 } 278 }
386 279
387 /// <summary> 280 /// <summary>
388 /// Update an asset's content 281 /// Update an asset's content
389 /// </summary> 282 /// </summary>
@@ -393,11 +286,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
393 /// <returns></returns> 286 /// <returns></returns>
394 public bool UpdateContent(string id, byte[] data) 287 public bool UpdateContent(string id, byte[] data)
395 { 288 {
289 if (String.IsNullOrEmpty(m_serverUrl))
290 {
291 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
292 throw new InvalidOperationException();
293 }
294
396 AssetBase asset = Get(id); 295 AssetBase asset = Get(id);
397 296
398 if (asset == null) 297 if (asset == null)
399 { 298 {
400 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating"); 299 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id);
401 return false; 300 return false;
402 } 301 }
403 302
@@ -420,83 +319,347 @@ namespace OpenSim.Services.Connectors.SimianGrid
420 throw new InvalidOperationException(); 319 throw new InvalidOperationException();
421 } 320 }
422 321
423 //string errorMessage = String.Empty;
424 string url = m_serverUrl + id;
425
426 if (m_cache != null) 322 if (m_cache != null)
427 m_cache.Expire(id); 323 m_cache.Expire(id);
428 324
325 return SimianDeleteOperation(id);
326 }
327
328#endregion IAssetService
329
330#region SimianOperations
331 /// <summary>
332 /// Invokes the xRemoveAsset operation on the simian server to delete an asset
333 /// </summary>
334 /// <param name="id"></param>
335 /// <returns></returns>
336 private bool SimianDeleteOperation(string id)
337 {
429 try 338 try
430 { 339 {
431 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); 340 NameValueCollection requestArgs = new NameValueCollection
432 request.Method = "DELETE"; 341 {
342 { "RequestMethod", "xRemoveAsset" },
343 { "AssetID", id }
344 };
433 345
434 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 346 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
347 if (! response["Success"].AsBoolean())
435 { 348 {
436 if (response.StatusCode != HttpStatusCode.NoContent) 349 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
437 { 350 return false;
438 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " +
439 response.StatusCode + " (" + response.StatusDescription + ")");
440 }
441 } 351 }
442 352
443 return true; 353 return true;
354
444 } 355 }
445 catch (Exception ex) 356 catch (Exception ex)
446 { 357 {
447 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message); 358 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message);
448 return false;
449 } 359 }
450 }
451 360
452 #endregion IAssetService 361 return false;
362 }
453 363
454 private AssetBase GetRemote(string id) 364 /// <summary>
365 /// Invokes the xAddAsset operation on the simian server to create or update an asset
366 /// </summary>
367 /// <param name="id"></param>
368 /// <returns></returns>
369 private string SimianStoreOperation(AssetBase asset)
455 { 370 {
456 AssetBase asset = null; 371 try
457 Uri url; 372 {
373 NameValueCollection requestArgs = new NameValueCollection
374 {
375 { "RequestMethod", "xAddAsset" },
376 { "ContentType", asset.Metadata.ContentType },
377 { "EncodedData", Convert.ToBase64String(asset.Data) },
378 { "AssetID", asset.FullID.ToString() },
379 { "CreatorID", asset.Metadata.CreatorID },
380 { "Temporary", asset.Temporary ? "1" : "0" },
381 { "Name", asset.Name }
382 };
383
384 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
385 if (! response["Success"].AsBoolean())
386 {
387 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString());
388 return null;
389 }
458 390
459 // Determine if id is an absolute URL or a grid-relative UUID 391 // asset.ID is always set before calling this function
460 if (!Uri.TryCreate(id, UriKind.Absolute, out url)) 392 return asset.ID;
461 url = new Uri(m_serverUrl + id); 393
394 }
395 catch (Exception ex)
396 {
397 m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
398 }
399
400 return null;
401 }
462 402
463 try 403 /// <summary>
404 /// Invokes the xGetAsset operation on the simian server to get data associated with an asset
405 /// </summary>
406 /// <param name="id"></param>
407 /// <returns></returns>
408 private AssetBase SimianGetOperation(string id)
409 {
410 try
464 { 411 {
465 HttpWebRequest request = UntrustedHttpWebRequest.Create(url); 412 NameValueCollection requestArgs = new NameValueCollection
413 {
414 { "RequestMethod", "xGetAsset" },
415 { "ID", id }
416 };
466 417
467 using (WebResponse response = request.GetResponse()) 418 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
419 if (! response["Success"].AsBoolean())
468 { 420 {
469 using (Stream responseStream = response.GetResponseStream()) 421 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
470 { 422 return null;
471 string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
472
473 // Create the asset object
474 asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
475
476 UUID assetID;
477 if (UUID.TryParse(id, out assetID))
478 asset.FullID = assetID;
479
480 // Grab the asset data from the response stream
481 using (MemoryStream stream = new MemoryStream())
482 {
483 responseStream.CopyStream(stream, Int32.MaxValue);
484 asset.Data = stream.ToArray();
485 }
486 }
487 } 423 }
424
425 AssetBase asset = new AssetBase();
488 426
489 // Cache store 427 asset.ID = id;
490 if (m_cache != null && asset != null) 428 asset.Name = String.Empty;
491 m_cache.Cache(asset); 429 asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property
430 asset.CreatorID = response["CreatorID"].AsString();
431 asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString());
432 asset.Local = false;
433 asset.Temporary = response["Temporary"];
492 434
493 return asset; 435 return asset;
494 } 436 }
495 catch (Exception ex) 437 catch (Exception ex)
496 { 438 {
497 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); 439 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message);
498 return null;
499 } 440 }
441
442 return null;
443 }
444
445 /// <summary>
446 /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset
447 /// This operation is generally used to determine if an asset exists in the database
448 /// </summary>
449 /// <param name="id"></param>
450 /// <returns></returns>
451 private AssetMetadata SimianGetMetadataOperation(string id)
452 {
453 try
454 {
455 NameValueCollection requestArgs = new NameValueCollection
456 {
457 { "RequestMethod", "xGetAssetMetadata" },
458 { "ID", id }
459 };
460
461 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
462 if (! response["Success"].AsBoolean())
463 {
464 // this is not really an error, this call is used to test existence
465 // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
466 return null;
467 }
468
469 AssetMetadata metadata = new AssetMetadata();
470 metadata.ID = id;
471 metadata.ContentType = response["ContentType"].AsString();
472 metadata.CreatorID = response["CreatorID"].AsString();
473 metadata.Local = false;
474 metadata.Temporary = response["Temporary"];
475
476 string lastModifiedStr = response["Last-Modified"].AsString();
477 if (! String.IsNullOrEmpty(lastModifiedStr))
478 {
479 DateTime lastModified;
480 if (DateTime.TryParse(lastModifiedStr, out lastModified))
481 metadata.CreationDate = lastModified;
482 }
483
484 return metadata;
485 }
486 catch (Exception ex)
487 {
488 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message);
489 }
490
491 return null;
500 } 492 }
493#endregion
494
495 // private AssetMetadata GetRemoteMetadata(string id)
496 // {
497 // Uri url;
498 // AssetMetadata metadata = null;
499
500 // // Determine if id is an absolute URL or a grid-relative UUID
501 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
502 // url = new Uri(m_serverUrl + id);
503
504 // try
505 // {
506 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
507 // request.Method = "HEAD";
508
509 // using (WebResponse response = request.GetResponse())
510 // {
511 // using (Stream responseStream = response.GetResponseStream())
512 // {
513 // // Create the metadata object
514 // metadata = new AssetMetadata();
515 // metadata.ContentType = response.ContentType;
516 // metadata.ID = id;
517
518 // UUID uuid;
519 // if (UUID.TryParse(id, out uuid))
520 // metadata.FullID = uuid;
521
522 // string lastModifiedStr = response.Headers.Get("Last-Modified");
523 // if (!String.IsNullOrEmpty(lastModifiedStr))
524 // {
525 // DateTime lastModified;
526 // if (DateTime.TryParse(lastModifiedStr, out lastModified))
527 // metadata.CreationDate = lastModified;
528 // }
529 // }
530 // }
531 // }
532 // catch (Exception ex)
533 // {
534 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
535 // }
536
537 // return metadata;
538 // }
539
540 // private AssetBase GetRemote(string id)
541 // {
542 // AssetBase asset = null;
543 // Uri url;
544
545 // // Determine if id is an absolute URL or a grid-relative UUID
546 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
547 // url = new Uri(m_serverUrl + id);
548
549 // try
550 // {
551 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
552
553 // using (WebResponse response = request.GetResponse())
554 // {
555 // using (Stream responseStream = response.GetResponseStream())
556 // {
557 // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
558
559 // // Create the asset object
560 // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
561
562 // UUID assetID;
563 // if (UUID.TryParse(id, out assetID))
564 // asset.FullID = assetID;
565
566 // // Grab the asset data from the response stream
567 // using (MemoryStream stream = new MemoryStream())
568 // {
569 // responseStream.CopyStream(stream, Int32.MaxValue);
570 // asset.Data = stream.ToArray();
571 // }
572 // }
573 // }
574
575 // // Cache store
576 // if (m_cache != null && asset != null)
577 // m_cache.Cache(asset);
578
579 // return asset;
580 // }
581 // catch (Exception ex)
582 // {
583 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
584 // return null;
585 // }
586 // }
587
588 // private string StoreRemote(AssetBase asset)
589 // {
590 // // Distinguish public and private assets
591 // bool isPublic = true;
592 // switch ((AssetType)asset.Type)
593 // {
594 // case AssetType.CallingCard:
595 // case AssetType.Gesture:
596 // case AssetType.LSLBytecode:
597 // case AssetType.LSLText:
598 // isPublic = false;
599 // break;
600 // }
601
602 // string errorMessage = null;
603
604 // // Build the remote storage request
605 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
606 // {
607 // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
608 // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
609 // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
610 // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
611 // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
612 // };
613
614 // // Make the remote storage request
615 // try
616 // {
617 // // Simian does not require the asset ID to be in the URL because it's in the post data.
618 // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
619 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
620
621 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
622 // {
623 // using (Stream responseStream = response.GetResponseStream())
624 // {
625 // string responseStr = null;
626
627 // try
628 // {
629 // responseStr = responseStream.GetStreamString();
630 // OSD responseOSD = OSDParser.Deserialize(responseStr);
631 // if (responseOSD.Type == OSDType.Map)
632 // {
633 // OSDMap responseMap = (OSDMap)responseOSD;
634 // if (responseMap["Success"].AsBoolean())
635 // return asset.ID;
636 // else
637 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
638 // }
639 // else
640 // {
641 // errorMessage = "Response format was invalid:\n" + responseStr;
642 // }
643 // }
644 // catch (Exception ex)
645 // {
646 // if (!String.IsNullOrEmpty(responseStr))
647 // errorMessage = "Failed to parse the response:\n" + responseStr;
648 // else
649 // errorMessage = "Failed to retrieve the response: " + ex.Message;
650 // }
651 // }
652 // }
653 // }
654 // catch (WebException ex)
655 // {
656 // errorMessage = ex.Message;
657 // }
658
659 // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
660 // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
661
662 // return null;
663 // }
501 } 664 }
502} 665}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 03b19ae..c402907 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -116,7 +116,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
116 { "UserID", principalID.ToString() } 116 { "UserID", principalID.ToString() }
117 }; 117 };
118 118
119 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 119 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
120 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) 120 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
121 { 121 {
122 bool md5hashFound = false; 122 bool md5hashFound = false;
@@ -159,7 +159,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
159 { "SessionID", token } 159 { "SessionID", token }
160 }; 160 };
161 161
162 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 162 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
163 if (response["Success"].AsBoolean()) 163 if (response["Success"].AsBoolean())
164 { 164 {
165 return true; 165 return true;
@@ -181,7 +181,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
181 { "UserID", principalID.ToString() } 181 { "UserID", principalID.ToString() }
182 }; 182 };
183 183
184 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 184 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
185 if (response["Success"].AsBoolean()) 185 if (response["Success"].AsBoolean())
186 { 186 {
187 return true; 187 return true;
@@ -204,7 +204,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
204 { "UserID", principalID.ToString() } 204 { "UserID", principalID.ToString() }
205 }; 205 };
206 206
207 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 207 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
208 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 208 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
209 { 209 {
210 OSDMap userMap = (OSDMap)response["User"]; 210 OSDMap userMap = (OSDMap)response["User"];
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
224 { "UserID", principalID.ToString() } 224 { "UserID", principalID.ToString() }
225 }; 225 };
226 226
227 response = WebUtil.PostToService(m_serverUrl, requestArgs); 227 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
228 bool success = response["Success"].AsBoolean(); 228 bool success = response["Success"].AsBoolean();
229 229
230 if (!success) 230 if (!success)
@@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
303 { "UserID", userID.ToString() } 303 { "UserID", userID.ToString() }
304 }; 304 };
305 305
306 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 306 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
307 if (response["Success"].AsBoolean()) 307 if (response["Success"].AsBoolean())
308 return response["SessionID"].AsUUID().ToString(); 308 return response["SessionID"].AsUUID().ToString();
309 else 309 else
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index 841bfa0..a397740 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
122 { "UserID", userID.ToString() } 122 { "UserID", userID.ToString() }
123 }; 123 };
124 124
125 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 125 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
126 if (response["Success"].AsBoolean()) 126 if (response["Success"].AsBoolean())
127 { 127 {
128 OSDMap map = null; 128 OSDMap map = null;
@@ -168,7 +168,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
168 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } 168 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
169 }; 169 };
170 170
171 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 171 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
172 bool success = response["Success"].AsBoolean(); 172 bool success = response["Success"].AsBoolean();
173 173
174 if (! success) 174 if (! success)
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 { "UserID", userID.ToString() } 189 { "UserID", userID.ToString() }
190 }; 190 };
191 191
192 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 192 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
193 if (response["Success"].AsBoolean()) 193 if (response["Success"].AsBoolean())
194 { 194 {
195 OSDMap map = null; 195 OSDMap map = null;
@@ -306,7 +306,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
306 { "LLAttachments", OSDParser.SerializeJsonString(items) } 306 { "LLAttachments", OSDParser.SerializeJsonString(items) }
307 }; 307 };
308 308
309 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 309 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
310 bool success = response["Success"].AsBoolean(); 310 bool success = response["Success"].AsBoolean();
311 311
312 if (!success) 312 if (!success)
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
new file mode 100644
index 0000000..764e71f
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
@@ -0,0 +1,180 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.IO;
33using System.Web;
34
35using log4net;
36using Nini.Config;
37using Mono.Addins;
38
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41
42using OpenSim.Framework;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Services.Interfaces;
46using Caps = OpenSim.Framework.Capabilities.Caps;
47
48namespace OpenSim.Services.Connectors.SimianGrid
49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
51 public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule
52 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
55 private bool m_enabled = true;
56 private Scene m_scene;
57 private String m_simianURL;
58
59#region IRegionModule Members
60
61 public string Name
62 {
63 get { return this.GetType().Name; }
64 }
65
66 public void Initialise(IConfigSource config)
67 {
68 try
69 {
70 IConfig m_config;
71
72 if ((m_config = config.Configs["SimianExternalCaps"]) != null)
73 {
74 m_enabled = m_config.GetBoolean("Enabled", m_enabled);
75 if ((m_config = config.Configs["SimianGrid"]) != null)
76 {
77 m_simianURL = m_config.GetString("SimianServiceURL");
78 if (String.IsNullOrEmpty(m_simianURL))
79 {
80 //m_log.DebugFormat("[SimianGrid] service URL is not defined");
81 m_enabled = false;
82 return;
83 }
84 }
85 }
86 else
87 m_enabled = false;
88 }
89 catch (Exception e)
90 {
91 m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
92 return;
93 }
94 }
95
96 public void PostInitialise() { }
97 public void Close() { }
98
99 public void AddRegion(Scene scene)
100 {
101 if (! m_enabled)
102 return;
103
104 m_scene = scene;
105 m_scene.RegisterModuleInterface<IExternalCapsModule>(this);
106 }
107
108 public void RemoveRegion(Scene scene)
109 {
110 if (! m_enabled)
111 return;
112
113 m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler;
114 m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler;
115 }
116
117 public void RegionLoaded(Scene scene)
118 {
119 if (! m_enabled)
120 return;
121
122 m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler;
123 m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler;
124 }
125
126 public Type ReplaceableInterface
127 {
128 get { return null; }
129 }
130
131#endregion
132
133#region IExternalCapsModule
134 // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/"
135 public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel)
136 {
137 UUID cap = UUID.Random();
138
139 // Call to simian to register the cap we generated
140 // NameValueCollection requestArgs = new NameValueCollection
141 // {
142 // { "RequestMethod", "AddCapability" },
143 // { "Resource", "user" },
144 // { "Expiration", 0 },
145 // { "OwnerID", agentID.ToString() },
146 // { "CapabilityID", cap.ToString() }
147 // };
148
149 // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs);
150
151 Dictionary<String,String> subs = new Dictionary<String,String>();
152 subs["%OP%"] = capName;
153 subs["%USR%"] = agentID.ToString();
154 subs["%CAP%"] = cap.ToString();
155 subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString();
156
157 caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs));
158 return true;
159 }
160
161#endregion
162
163#region EventHandlers
164 public void RegisterCapsEventHandler(UUID agentID, Caps caps) { }
165 public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { }
166#endregion
167
168 private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs)
169 {
170 String result = urlSkel;
171
172 foreach (KeyValuePair<String,String> kvp in subs)
173 {
174 result = result.Replace(kvp.Key,kvp.Value);
175 }
176
177 return result;
178 }
179 }
180} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 7422d94..9a8164c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
153 { "Value", flags.ToString() } 153 { "Value", flags.ToString() }
154 }; 154 };
155 155
156 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 156 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
157 bool success = response["Success"].AsBoolean(); 157 bool success = response["Success"].AsBoolean();
158 158
159 if (!success) 159 if (!success)
@@ -180,7 +180,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
180 { "Key", friend } 180 { "Key", friend }
181 }; 181 };
182 182
183 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 183 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
184 bool success = response["Success"].AsBoolean(); 184 bool success = response["Success"].AsBoolean();
185 185
186 if (!success) 186 if (!success)
@@ -200,7 +200,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
200 { "Type", "Friend" } 200 { "Type", "Friend" }
201 }; 201 };
202 202
203 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 203 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
204 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 204 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
205 { 205 {
206 return (OSDArray)response["Entries"]; 206 return (OSDArray)response["Entries"];
@@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
221 { "Type", "Friend" } 221 { "Type", "Friend" }
222 }; 222 };
223 223
224 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 224 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
225 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 225 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
226 { 226 {
227 return (OSDArray)response["Entries"]; 227 return (OSDArray)response["Entries"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
index 847319c..9898da9 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
@@ -26,8 +26,122 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Collections.Specialized;
31using System.Reflection;
32using log4net;
29using Mono.Addins; 33using Mono.Addins;
30using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
31 41
32[assembly: Addin("SimianGrid", "1.0")] 42[assembly: Addin("SimianGrid", "1.0")]
33[assembly: AddinDependency("OpenSim", "0.5")] 43[assembly: AddinDependency("OpenSim", "0.5")]
44
45namespace OpenSim.Services.Connectors.SimianGrid
46{
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
48 public class SimianGrid : ISharedRegionModule
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private IConfig m_config = null;
53
54 private String m_simianURL;
55
56#region IRegionModule Members
57
58 public string Name
59 {
60 get { return this.GetType().Name; }
61 }
62
63 public void Initialise(IConfigSource config)
64 {
65 try
66 {
67 m_config = config.Configs["SimianGrid"];
68
69 if (m_config != null)
70 {
71 m_simianURL = m_config.GetString("SimianServiceURL");
72 if (String.IsNullOrEmpty(m_simianURL))
73 {
74 // m_log.DebugFormat("[SimianGrid] service URL is not defined");
75 return;
76 }
77
78 InitialiseSimCap();
79 SimulatorCapability = SimulatorCapability.Trim();
80 m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
81 }
82 }
83 catch (Exception e)
84 {
85 m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
86 return;
87 }
88 }
89
90 public void PostInitialise() { }
91 public void Close() { }
92 public void AddRegion(Scene scene) { }
93 public void RemoveRegion(Scene scene) { }
94 public void RegionLoaded(Scene scene) { }
95
96 public Type ReplaceableInterface
97 {
98 get { return null; }
99 }
100
101 ///<summary>
102 /// Try a variety of methods for finding the simian simulator capability; first check the
103 /// configuration itself, then look for a file that contains the cap, then finally look
104 /// for an environment variable that contains it.
105 ///</summary>
106 private void InitialiseSimCap()
107 {
108 if (m_config.Contains("SimulatorCapability"))
109 {
110 SimulatorCapability = m_config.GetString("SimulatorCapability");
111 return;
112 }
113
114 if (m_config.Contains("SimulatorCapabilityFile"))
115 {
116 String filename = m_config.GetString("SimulatorCapabilityFile");
117 if (System.IO.File.Exists(filename))
118 {
119 SimulatorCapability = System.IO.File.ReadAllText(filename);
120 return;
121 }
122 }
123
124 if (m_config.Contains("SimulatorCapabilityVariable"))
125 {
126 String envname = m_config.GetString("SimulatorCapabilityVariable");
127 String envvalue = System.Environment.GetEnvironmentVariable(envname);
128 if (envvalue != null)
129 {
130 SimulatorCapability = envvalue;
131 return;
132 }
133 }
134
135 m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
136 }
137
138#endregion
139
140 public static String SimulatorCapability = UUID.Zero.ToString();
141 public static OSDMap PostToService(string url, NameValueCollection data)
142 {
143 data["cap"] = SimulatorCapability;
144 return WebUtil.PostToService(url, data);
145 }
146 }
147} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
index 93fdae3..b999509 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized;
30using System.Reflection; 31using System.Reflection;
31using System.Net; 32using System.Net;
32using System.IO; 33using System.IO;
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes;
43using OpenMetaverse; 44using OpenMetaverse;
44using OpenMetaverse.StructuredData; 45using OpenMetaverse.StructuredData;
45 46
46namespace OpenSim.Region.OptionalModules.Simian 47//namespace OpenSim.Region.OptionalModules.Simian
48namespace OpenSim.Services.Connectors.SimianGrid
47{ 49{
48 /// <summary> 50 /// <summary>
49 /// </summary> 51 /// </summary>
@@ -196,67 +198,84 @@ namespace OpenSim.Region.OptionalModules.Simian
196 } 198 }
197 } 199 }
198 200
199 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() 201 NameValueCollection requestArgs = new NameValueCollection
202 {
203 { "RequestMethod", "xAddMapTile" },
204 { "X", scene.RegionInfo.RegionLocX.ToString() },
205 { "Y", scene.RegionInfo.RegionLocY.ToString() },
206 { "ContentType", "image/png" },
207 { "EncodedData", System.Convert.ToBase64String(pngData) }
208 };
209
210 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
211 if (! response["Success"].AsBoolean())
200 { 212 {
201 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), 213 m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
202 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), 214 return;
203 new MultipartForm.File("Tile", "tile.png", "image/png", pngData) 215 }
204 };
205 216
206 string errorMessage = null; 217 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
207 int tickstart = Util.EnvironmentTickCount(); 218 // {
219 // new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
220 // new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
221 // new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
222 // };
208 223
209 // Make the remote storage request 224 // string errorMessage = null;
210 try 225 // int tickstart = Util.EnvironmentTickCount();
211 {
212 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
213 request.Timeout = 20000;
214 request.ReadWriteTimeout = 5000;
215 226
216 using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) 227 // // Make the remote storage request
217 { 228 // try
218 using (Stream responseStream = response.GetResponseStream()) 229 // {
219 { 230 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
220 string responseStr = responseStream.GetStreamString(); 231 // request.Timeout = 20000;
221 OSD responseOSD = OSDParser.Deserialize(responseStr); 232 // request.ReadWriteTimeout = 5000;
222 if (responseOSD.Type == OSDType.Map)
223 {
224 OSDMap responseMap = (OSDMap)responseOSD;
225 if (responseMap["Success"].AsBoolean())
226 return;
227 233
228 errorMessage = "Upload failed: " + responseMap["Message"].AsString(); 234 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
229 } 235 // {
230 else 236 // using (Stream responseStream = response.GetResponseStream())
231 { 237 // {
232 errorMessage = "Response format was invalid:\n" + responseStr; 238 // string responseStr = responseStream.GetStreamString();
233 } 239 // OSD responseOSD = OSDParser.Deserialize(responseStr);
234 } 240 // if (responseOSD.Type == OSDType.Map)
235 } 241 // {
236 } 242 // OSDMap responseMap = (OSDMap)responseOSD;
237 catch (WebException we) 243 // if (responseMap["Success"].AsBoolean())
238 { 244 // return;
239 errorMessage = we.Message; 245
240 if (we.Status == WebExceptionStatus.ProtocolError) 246 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
241 { 247 // }
242 HttpWebResponse webResponse = (HttpWebResponse)we.Response; 248 // else
243 errorMessage = String.Format("[{0}] {1}", 249 // {
244 webResponse.StatusCode,webResponse.StatusDescription); 250 // errorMessage = "Response format was invalid:\n" + responseStr;
245 } 251 // }
246 } 252 // }
247 catch (Exception ex) 253 // }
248 { 254 // }
249 errorMessage = ex.Message; 255 // catch (WebException we)
250 } 256 // {
251 finally 257 // errorMessage = we.Message;
252 { 258 // if (we.Status == WebExceptionStatus.ProtocolError)
253 // This just dumps a warning for any operation that takes more than 100 ms 259 // {
254 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 260 // HttpWebResponse webResponse = (HttpWebResponse)we.Response;
255 m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); 261 // errorMessage = String.Format("[{0}] {1}",
256 } 262 // webResponse.StatusCode,webResponse.StatusDescription);
263 // }
264 // }
265 // catch (Exception ex)
266 // {
267 // errorMessage = ex.Message;
268 // }
269 // finally
270 // {
271 // // This just dumps a warning for any operation that takes more than 100 ms
272 // int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
273 // m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
274 // }
275
276 // m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
277 // pngData.Length, scene.RegionInfo.RegionName, errorMessage);
257 278
258 m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
259 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
260 } 279 }
261 } 280 }
262} \ No newline at end of file 281} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 20eaa3a..3cf3416 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -140,7 +140,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
140 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 140 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
141 }; 141 };
142 142
143 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 143 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
144 if (response["Success"].AsBoolean()) 144 if (response["Success"].AsBoolean())
145 return String.Empty; 145 return String.Empty;
146 else 146 else
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 { "Enabled", "0" } 156 { "Enabled", "0" }
157 }; 157 };
158 158
159 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 159 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
160 bool success = response["Success"].AsBoolean(); 160 bool success = response["Success"].AsBoolean();
161 161
162 if (!success) 162 if (!success)
@@ -203,7 +203,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
203 203
204 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); 204 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
205 205
206 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 206 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
207 if (response["Success"].AsBoolean()) 207 if (response["Success"].AsBoolean())
208 { 208 {
209 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); 209 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
@@ -231,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
231 231
232 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); 232 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
233 233
234 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 234 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
235 if (response["Success"].AsBoolean()) 235 if (response["Success"].AsBoolean())
236 { 236 {
237 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); 237 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
@@ -272,7 +272,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
272 272
273 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); 273 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
274 274
275 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 275 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
276 if (response["Success"].AsBoolean()) 276 if (response["Success"].AsBoolean())
277 { 277 {
278 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 278 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -310,7 +310,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
310 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); 310 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
311 311
312 312
313 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 313 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
314 if (response["Success"].AsBoolean()) 314 if (response["Success"].AsBoolean())
315 { 315 {
316 OSDArray array = response["Scenes"] as OSDArray; 316 OSDArray array = response["Scenes"] as OSDArray;
@@ -341,6 +341,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
341 return new List<GridRegion>(0); 341 return new List<GridRegion>(0);
342 } 342 }
343 343
344 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
345 {
346 // TODO: Allow specifying the default grid location
347 return GetDefaultRegions(scopeID);
348 }
349
344 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 350 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
345 { 351 {
346 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); 352 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);
@@ -361,7 +367,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
361 { "Enabled", "1" } 367 { "Enabled", "1" }
362 }; 368 };
363 369
364 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 370 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
365 if (response["Success"].AsBoolean()) 371 if (response["Success"].AsBoolean())
366 { 372 {
367 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 373 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -391,7 +397,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
391 397
392 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); 398 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
393 399
394 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 400 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
395 if (response["Success"].AsBoolean()) 401 if (response["Success"].AsBoolean())
396 { 402 {
397 OSDMap extraData = response["ExtraData"] as OSDMap; 403 OSDMap extraData = response["ExtraData"] as OSDMap;
@@ -498,7 +504,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
498 if (onlyEnabled) 504 if (onlyEnabled)
499 requestArgs["Enabled"] = "1"; 505 requestArgs["Enabled"] = "1";
500 506
501 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 507 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
502 if (response["Success"].AsBoolean()) 508 if (response["Success"].AsBoolean())
503 { 509 {
504 return ResponseToGridRegion(response); 510 return ResponseToGridRegion(response);
@@ -525,9 +531,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
525 region.RegionName = response["Name"].AsString(); 531 region.RegionName = response["Name"].AsString();
526 532
527 Vector3d minPosition = response["MinPosition"].AsVector3d(); 533 Vector3d minPosition = response["MinPosition"].AsVector3d();
534 Vector3d maxPosition = response["MaxPosition"].AsVector3d();
528 region.RegionLocX = (int)minPosition.X; 535 region.RegionLocX = (int)minPosition.X;
529 region.RegionLocY = (int)minPosition.Y; 536 region.RegionLocY = (int)minPosition.Y;
530 537
538 region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
539 region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
540
531 if ( ! extraData["HyperGrid"] ) { 541 if ( ! extraData["HyperGrid"] ) {
532 Uri httpAddress = response["Address"].AsUri(); 542 Uri httpAddress = response["Address"].AsUri();
533 region.ExternalHostName = httpAddress.Host; 543 region.ExternalHostName = httpAddress.Host;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 36325ce..97eaabe 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 { "OwnerID", userID.ToString() } 156 { "OwnerID", userID.ToString() }
157 }; 157 };
158 158
159 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 159 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
160 bool success = response["Success"].AsBoolean(); 160 bool success = response["Success"].AsBoolean();
161 161
162 if (!success) 162 if (!success)
@@ -182,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
182 { "ChildrenOnly", "0" } 182 { "ChildrenOnly", "0" }
183 }; 183 };
184 184
185 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 185 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
186 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 186 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
187 { 187 {
188 OSDArray items = (OSDArray)response["Items"]; 188 OSDArray items = (OSDArray)response["Items"];
@@ -244,7 +244,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
244 { "ChildrenOnly", "1" } 244 { "ChildrenOnly", "1" }
245 }; 245 };
246 246
247 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 247 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
248 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 248 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
249 { 249 {
250 OSDArray items = (OSDArray)response["Items"]; 250 OSDArray items = (OSDArray)response["Items"];
@@ -274,7 +274,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
274 { "OwnerID", userID.ToString() } 274 { "OwnerID", userID.ToString() }
275 }; 275 };
276 276
277 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 277 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
278 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) 278 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap)
279 { 279 {
280 OSDMap folder = (OSDMap)response["Folder"]; 280 OSDMap folder = (OSDMap)response["Folder"];
@@ -312,7 +312,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
312 { "ChildrenOnly", "1" } 312 { "ChildrenOnly", "1" }
313 }; 313 };
314 314
315 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 315 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
316 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 316 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
317 { 317 {
318 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); 318 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]);
@@ -349,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
349 { "ChildrenOnly", "1" } 349 { "ChildrenOnly", "1" }
350 }; 350 };
351 351
352 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 352 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
354 { 354 {
355 OSDArray items = (OSDArray)response["Items"]; 355 OSDArray items = (OSDArray)response["Items"];
@@ -383,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
383 { "ChildrenOnly", "1" } 383 { "ChildrenOnly", "1" }
384 }; 384 };
385 385
386 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 386 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
387 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 387 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
388 { 388 {
389 OSDArray items = (OSDArray)response["Items"]; 389 OSDArray items = (OSDArray)response["Items"];
@@ -423,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
423 { "ChildrenOnly", "1" } 423 { "ChildrenOnly", "1" }
424 }; 424 };
425 425
426 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 426 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
427 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 427 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
428 { 428 {
429 OSDArray items = (OSDArray)response["Items"]; 429 OSDArray items = (OSDArray)response["Items"];
@@ -454,7 +454,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
454 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } 454 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) }
455 }; 455 };
456 456
457 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 457 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
458 bool success = response["Success"].AsBoolean(); 458 bool success = response["Success"].AsBoolean();
459 459
460 if (!success) 460 if (!success)
@@ -518,7 +518,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
518 { "ItemID", itemID.ToString() } 518 { "ItemID", itemID.ToString() }
519 }; 519 };
520 520
521 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 521 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
522 bool success = response["Success"].AsBoolean(); 522 bool success = response["Success"].AsBoolean();
523 523
524 if (!success) 524 if (!success)
@@ -546,7 +546,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
546 { "FolderID", folder.ID.ToString() } 546 { "FolderID", folder.ID.ToString() }
547 }; 547 };
548 548
549 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 549 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
550 bool success = response["Success"].AsBoolean(); 550 bool success = response["Success"].AsBoolean();
551 551
552 if (!success) 552 if (!success)
@@ -623,7 +623,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
623 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 623 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
624 }; 624 };
625 625
626 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 626 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
627 bool success = response["Success"].AsBoolean(); 627 bool success = response["Success"].AsBoolean();
628 628
629 if (!success) 629 if (!success)
@@ -847,7 +847,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
847 { "Items", String.Join(",", itemIDs) } 847 { "Items", String.Join(",", itemIDs) }
848 }; 848 };
849 849
850 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 850 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
851 bool success = response["Success"].AsBoolean(); 851 bool success = response["Success"].AsBoolean();
852 852
853 if (!success) 853 if (!success)
@@ -885,7 +885,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
885 { "UserID", userID.ToString() } 885 { "UserID", userID.ToString() }
886 }; 886 };
887 887
888 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 888 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
889 if (response["Success"].AsBoolean()) 889 if (response["Success"].AsBoolean())
890 { 890 {
891 OSDMap user = response["User"] as OSDMap; 891 OSDMap user = response["User"] as OSDMap;
@@ -916,7 +916,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
916 { "Gestures", OSDParser.SerializeJsonString(gestures) } 916 { "Gestures", OSDParser.SerializeJsonString(gestures) }
917 }; 917 };
918 918
919 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 919 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
920 if (!response["Success"].AsBoolean()) 920 if (!response["Success"].AsBoolean())
921 { 921 {
922 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + 922 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " +
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 854bea4..211b775 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 public void PostInitialise() { } 65 public void PostInitialise() { }
66 public void Close() { } 66 public void Close() { }
67 67
68 public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); } 68 public SimianPresenceServiceConnector() { }
69 public string Name { get { return "SimianPresenceServiceConnector"; } } 69 public string Name { get { return "SimianPresenceServiceConnector"; } }
70 public void AddRegion(Scene scene) 70 public void AddRegion(Scene scene)
71 { 71 {
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
122 serviceUrl = serviceUrl + '/'; 122 serviceUrl = serviceUrl + '/';
123 m_serverUrl = serviceUrl; 123 m_serverUrl = serviceUrl;
124 m_activityDetector = new SimianActivityDetector(this);
124 m_Enabled = true; 125 m_Enabled = true;
125 } 126 }
126 } 127 }
@@ -137,17 +138,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
137 userID, sessionID, secureSessionID); 138 userID, sessionID, secureSessionID);
138 139
139 NameValueCollection requestArgs = new NameValueCollection 140 NameValueCollection requestArgs = new NameValueCollection
140 { 141 {
141 { "RequestMethod", "AddSession" }, 142 { "RequestMethod", "AddSession" },
142 { "UserID", userID.ToString() } 143 { "UserID", userID.ToString() }
143 }; 144 };
145
144 if (sessionID != UUID.Zero) 146 if (sessionID != UUID.Zero)
145 { 147 {
146 requestArgs["SessionID"] = sessionID.ToString(); 148 requestArgs["SessionID"] = sessionID.ToString();
147 requestArgs["SecureSessionID"] = secureSessionID.ToString(); 149 requestArgs["SecureSessionID"] = secureSessionID.ToString();
148 } 150 }
149 151
150 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 152 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
151 bool success = response["Success"].AsBoolean(); 153 bool success = response["Success"].AsBoolean();
152 154
153 if (!success) 155 if (!success)
@@ -158,15 +160,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
158 160
159 public bool LogoutAgent(UUID sessionID) 161 public bool LogoutAgent(UUID sessionID)
160 { 162 {
161// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 163 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
162 164
163 NameValueCollection requestArgs = new NameValueCollection 165 NameValueCollection requestArgs = new NameValueCollection
164 { 166 {
165 { "RequestMethod", "RemoveSession" }, 167 { "RequestMethod", "RemoveSession" },
166 { "SessionID", sessionID.ToString() } 168 { "SessionID", sessionID.ToString() }
167 }; 169 };
168 170
169 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 171 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
170 bool success = response["Success"].AsBoolean(); 172 bool success = response["Success"].AsBoolean();
171 173
172 if (!success) 174 if (!success)
@@ -177,15 +179,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
177 179
178 public bool LogoutRegionAgents(UUID regionID) 180 public bool LogoutRegionAgents(UUID regionID)
179 { 181 {
180// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); 182 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
181 183
182 NameValueCollection requestArgs = new NameValueCollection 184 NameValueCollection requestArgs = new NameValueCollection
183 { 185 {
184 { "RequestMethod", "RemoveSessions" }, 186 { "RequestMethod", "RemoveSessions" },
185 { "SceneID", regionID.ToString() } 187 { "SceneID", regionID.ToString() }
186 }; 188 };
187 189
188 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 190 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
189 bool success = response["Success"].AsBoolean(); 191 bool success = response["Success"].AsBoolean();
190 192
191 if (!success) 193 if (!success)
@@ -202,49 +204,46 @@ namespace OpenSim.Services.Connectors.SimianGrid
202 204
203 public PresenceInfo GetAgent(UUID sessionID) 205 public PresenceInfo GetAgent(UUID sessionID)
204 { 206 {
205// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID); 207 OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID);
206 208 if (sessionResponse == null)
207 NameValueCollection requestArgs = new NameValueCollection
208 {
209 { "RequestMethod", "GetSession" },
210 { "SessionID", sessionID.ToString() }
211 };
212
213 OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
214 if (sessionResponse["Success"].AsBoolean())
215 { 209 {
216 UUID userID = sessionResponse["UserID"].AsUUID(); 210 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
217 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 211 return null;
218
219 requestArgs = new NameValueCollection
220 {
221 { "RequestMethod", "GetUser" },
222 { "UserID", userID.ToString() }
223 };
224
225 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
226 if (userResponse["Success"].AsBoolean())
227 return ResponseToPresenceInfo(sessionResponse, userResponse);
228 else
229 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
230 } 212 }
231 else 213
214 UUID userID = sessionResponse["UserID"].AsUUID();
215 OSDMap userResponse = GetUserData(userID);
216 if (userResponse == null)
232 { 217 {
233 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString()); 218 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
219 return null;
234 } 220 }
235 221
236 return null; 222 return ResponseToPresenceInfo(sessionResponse);
237 } 223 }
238 224
239 public PresenceInfo[] GetAgents(string[] userIDs) 225 public PresenceInfo[] GetAgents(string[] userIDs)
240 { 226 {
241 List<PresenceInfo> presences = new List<PresenceInfo>(userIDs.Length); 227 List<PresenceInfo> presences = new List<PresenceInfo>();
228
229 NameValueCollection requestArgs = new NameValueCollection
230 {
231 { "RequestMethod", "GetSessions" },
232 { "UserIDList", String.Join(",",userIDs) }
233 };
242 234
243 for (int i = 0; i < userIDs.Length; i++) 235 OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs);
236 if (! sessionListResponse["Success"].AsBoolean())
244 { 237 {
245 UUID userID; 238 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
246 if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero) 239 return null;
247 presences.AddRange(GetSessions(userID)); 240 }
241
242 OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
243 for (int i = 0; i < sessionList.Count; i++)
244 {
245 OSDMap sessionInfo = sessionList[i] as OSDMap;
246 presences.Add(ResponseToPresenceInfo(sessionInfo));
248 } 247 }
249 248
250 return presences.ToArray(); 249 return presences.ToArray();
@@ -262,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
262 261
263 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 262 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
264 { 263 {
265// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); 264 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
266 265
267 // Remove the session to mark this user offline 266 // Remove the session to mark this user offline
268 if (!LogoutAgent(sessionID)) 267 if (!LogoutAgent(sessionID))
@@ -270,13 +269,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
270 269
271 // Save our last position as user data 270 // Save our last position as user data
272 NameValueCollection requestArgs = new NameValueCollection 271 NameValueCollection requestArgs = new NameValueCollection
273 { 272 {
274 { "RequestMethod", "AddUserData" }, 273 { "RequestMethod", "AddUserData" },
275 { "UserID", userID.ToString() }, 274 { "UserID", userID.ToString() },
276 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } 275 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
277 }; 276 };
278 277
279 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 278 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
280 bool success = response["Success"].AsBoolean(); 279 bool success = response["Success"].AsBoolean();
281 280
282 if (!success) 281 if (!success)
@@ -287,16 +286,16 @@ namespace OpenSim.Services.Connectors.SimianGrid
287 286
288 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
289 { 288 {
290// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 289 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
291 290
292 NameValueCollection requestArgs = new NameValueCollection 291 NameValueCollection requestArgs = new NameValueCollection
293 { 292 {
294 { "RequestMethod", "AddUserData" }, 293 { "RequestMethod", "AddUserData" },
295 { "UserID", userID.ToString() }, 294 { "UserID", userID.ToString() },
296 { "HomeLocation", SerializeLocation(regionID, position, lookAt) } 295 { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
297 }; 296 };
298 297
299 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 298 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
300 bool success = response["Success"].AsBoolean(); 299 bool success = response["Success"].AsBoolean();
301 300
302 if (!success) 301 if (!success)
@@ -312,24 +311,19 @@ namespace OpenSim.Services.Connectors.SimianGrid
312 311
313 public GridUserInfo GetGridUserInfo(string user) 312 public GridUserInfo GetGridUserInfo(string user)
314 { 313 {
315// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); 314 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316 315
317 UUID userID = new UUID(user); 316 UUID userID = new UUID(user);
318// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 317 OSDMap userResponse = GetUserData(userID);
319 318
320 NameValueCollection requestArgs = new NameValueCollection 319 if (userResponse == null)
321 { 320 {
322 { "RequestMethod", "GetUser" }, 321 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID);
323 { "UserID", userID.ToString() } 322 }
324 };
325 323
326 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); 324 // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null.
327 if (userResponse["Success"].AsBoolean()) 325 return ResponseToGridUserInfo(userResponse);
328 return ResponseToGridUserInfo(userResponse);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331 326
332 return null;
333 } 327 }
334 328
335 #endregion 329 #endregion
@@ -338,67 +332,51 @@ namespace OpenSim.Services.Connectors.SimianGrid
338 332
339 private OSDMap GetUserData(UUID userID) 333 private OSDMap GetUserData(UUID userID)
340 { 334 {
341// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 335 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
342 336
343 NameValueCollection requestArgs = new NameValueCollection 337 NameValueCollection requestArgs = new NameValueCollection
344 { 338 {
345 { "RequestMethod", "GetUser" }, 339 { "RequestMethod", "GetUser" },
346 { "UserID", userID.ToString() } 340 { "UserID", userID.ToString() }
347 }; 341 };
348 342
349 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 343 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
350 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 344 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
351 return response; 345 return response;
352 else
353 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString());
354 346
347 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString());
355 return null; 348 return null;
356 } 349 }
357 350
358 private List<PresenceInfo> GetSessions(UUID userID) 351 private OSDMap GetSessionDataFromSessionID(UUID sessionID)
359 { 352 {
360 List<PresenceInfo> presences = new List<PresenceInfo>(1); 353 NameValueCollection requestArgs = new NameValueCollection
361
362 OSDMap userResponse = GetUserData(userID);
363 if (userResponse != null)
364 {
365// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID);
366
367 NameValueCollection requestArgs = new NameValueCollection
368 { 354 {
369 { "RequestMethod", "GetSession" }, 355 { "RequestMethod", "GetSession" },
370 { "UserID", userID.ToString() } 356 { "SessionID", sessionID.ToString() }
371 }; 357 };
372 358
373 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 359 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
374 if (response["Success"].AsBoolean()) 360 if (response["Success"].AsBoolean())
375 { 361 return response;
376 PresenceInfo presence = ResponseToPresenceInfo(response, userResponse);
377 if (presence != null)
378 presences.Add(presence);
379 }
380// else
381// {
382// m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString());
383// }
384 }
385 362
386 return presences; 363 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString());
364 return null;
387 } 365 }
388 366
389 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 367 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
390 { 368 {
391 // Save our current location as session data 369 // Save our current location as session data
392 NameValueCollection requestArgs = new NameValueCollection 370 NameValueCollection requestArgs = new NameValueCollection
393 { 371 {
394 { "RequestMethod", "UpdateSession" }, 372 { "RequestMethod", "UpdateSession" },
395 { "SessionID", sessionID.ToString() }, 373 { "SessionID", sessionID.ToString() },
396 { "SceneID", regionID.ToString() }, 374 { "SceneID", regionID.ToString() },
397 { "ScenePosition", lastPosition.ToString() }, 375 { "ScenePosition", lastPosition.ToString() },
398 { "SceneLookAt", lastLookAt.ToString() } 376 { "SceneLookAt", lastLookAt.ToString() }
399 }; 377 };
400 378
401 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 379 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
402 bool success = response["Success"].AsBoolean(); 380 bool success = response["Success"].AsBoolean();
403 381
404 if (!success) 382 if (!success)
@@ -407,7 +385,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
407 return success; 385 return success;
408 } 386 }
409 387
410 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) 388 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse)
411 { 389 {
412 if (sessionResponse == null) 390 if (sessionResponse == null)
413 return null; 391 return null;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
index bd8069f..684a0db 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
@@ -392,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
392 { "UserID", client.AgentId.ToString() } 392 { "UserID", client.AgentId.ToString() }
393 }; 393 };
394 394
395 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 395 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
396 string email = response["Email"].AsString(); 396 string email = response["Email"].AsString();
397 397
398 if (!response["Success"].AsBoolean()) 398 if (!response["Success"].AsBoolean())
@@ -443,7 +443,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
443 { key, OSDParser.SerializeJsonString(value) } 443 { key, OSDParser.SerializeJsonString(value) }
444 }; 444 };
445 445
446 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 446 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
447 bool success = response["Success"].AsBoolean(); 447 bool success = response["Success"].AsBoolean();
448 448
449 if (!success) 449 if (!success)
@@ -462,7 +462,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
462 { "UserID", userID.ToString() } 462 { "UserID", userID.ToString() }
463 }; 463 };
464 464
465 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 465 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
466 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 466 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
467 { 467 {
468 return (OSDMap)response["User"]; 468 return (OSDMap)response["User"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index fcb5115..fdc8697 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -165,7 +165,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
165 { "NameQuery", query } 165 { "NameQuery", query }
166 }; 166 };
167 167
168 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 168 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
169 if (response["Success"].AsBoolean()) 169 if (response["Success"].AsBoolean())
170 { 170 {
171 OSDArray array = response["Users"] as OSDArray; 171 OSDArray array = response["Users"] as OSDArray;
@@ -209,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
209 { "AccessLevel", data.UserLevel.ToString() } 209 { "AccessLevel", data.UserLevel.ToString() }
210 }; 210 };
211 211
212 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 212 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
213 213
214 if (response["Success"].AsBoolean()) 214 if (response["Success"].AsBoolean())
215 { 215 {
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
224 { "UserTitle", data.UserTitle } 224 { "UserTitle", data.UserTitle }
225 }; 225 };
226 226
227 response = WebUtil.PostToService(m_serverUrl, requestArgs); 227 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
228 bool success = response["Success"].AsBoolean(); 228 bool success = response["Success"].AsBoolean();
229 229
230 if (success) 230 if (success)
@@ -257,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
257 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; 257 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)";
258// m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); 258// m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue);
259 259
260 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 260 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
261 if (response["Success"].AsBoolean()) 261 if (response["Success"].AsBoolean())
262 { 262 {
263 OSDMap user = response["User"] as OSDMap; 263 OSDMap user = response["User"] as OSDMap;