aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authordiva2009-04-05 03:27:50 +0000
committerdiva2009-04-05 03:27:50 +0000
commit3c9cba162739b93a07067d8a286f6dad55e02217 (patch)
treec4f9054f524b002b37e4d36a382c206b028f25d9 /OpenSim/Framework
parent* Fixed copyright headers on HyperGrid source files. (Now match the rest of O... (diff)
downloadopensim-SC_OLD-3c9cba162739b93a07067d8a286f6dad55e02217.zip
opensim-SC_OLD-3c9cba162739b93a07067d8a286f6dad55e02217.tar.gz
opensim-SC_OLD-3c9cba162739b93a07067d8a286f6dad55e02217.tar.bz2
opensim-SC_OLD-3c9cba162739b93a07067d8a286f6dad55e02217.tar.xz
Added CreateObject(regionhandle, userID, itemID) to post objects that are to be fetched from the user's inventory server and rezzed in the region. Added all code necessary to fetch the item and the asset, and rez it inworld. The access to the item is uncap-ed and unverified -- I may place it later either under a cap or with auth verification. But in this model regions don't have the user's inventory, so they would have to guess the item IDs.
Added safemode config to Standalone Hypergrid, similar effect to AllowRegionAccessToInventory in Inventory Server. Everyone should have these vars set to their default values except me!
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Clients/InventoryClient.cs78
-rw-r--r--OpenSim/Framework/Communications/Clients/RegionClient.cs76
-rw-r--r--OpenSim/Framework/Communications/Services/HGInventoryService.cs18
3 files changed, 171 insertions, 1 deletions
diff --git a/OpenSim/Framework/Communications/Clients/InventoryClient.cs b/OpenSim/Framework/Communications/Clients/InventoryClient.cs
new file mode 100644
index 0000000..8fe4268
--- /dev/null
+++ b/OpenSim/Framework/Communications/Clients/InventoryClient.cs
@@ -0,0 +1,78 @@
1/**
2 * Copyright (c), Contributors. All rights reserved.
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the Organizations nor the names of Individual
14 * Contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25 * OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29using System;
30using OpenSim.Framework.Servers;
31
32using OpenMetaverse;
33
34namespace OpenSim.Framework.Communications.Clients
35{
36 public class InventoryClient
37 {
38 private string ServerURL;
39
40 public InventoryClient(string url)
41 {
42 ServerURL = url;
43 }
44
45 public void GetInventoryItemAsync(InventoryItemBase item, ReturnResponse<InventoryItemBase> callBack)
46 {
47 System.Console.WriteLine("[HGrid] GetInventory from " + ServerURL);
48 try
49 {
50 RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase> requester
51 = new RestSessionObjectPosterResponse<InventoryItemBase, InventoryItemBase>();
52 requester.ResponseCallback = callBack;
53
54 requester.BeginPostObject(ServerURL + "/GetItem/", item, string.Empty, string.Empty);
55 }
56 catch (Exception e)
57 {
58 System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
59 }
60 }
61
62 public InventoryItemBase GetInventoryItem(InventoryItemBase item)
63 {
64 System.Console.WriteLine("[HGrid] GetInventory " + item.ID + " from " + ServerURL);
65 try
66 {
67 item = SynchronousRestSessionObjectPoster<Guid, InventoryItemBase>.BeginPostObject("POST", ServerURL + "/GetItem/", item.ID.Guid, "", "");
68 return item;
69 }
70 catch (Exception e)
71 {
72 System.Console.WriteLine("[HGrid]: Exception posting to inventory: " + e);
73 }
74 return null;
75 }
76
77 }
78}
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs
index d98852b..196bcf9 100644
--- a/OpenSim/Framework/Communications/Clients/RegionClient.cs
+++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs
@@ -417,6 +417,82 @@ namespace OpenSim.Framework.Communications.Clients
417 417
418 } 418 }
419 419
420 public bool DoCreateObjectCall(RegionInfo region, UUID userID, UUID itemID)
421 {
422 ulong regionHandle = GetRegionHandle(region.RegionHandle);
423 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/";
424 //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri);
425
426 WebRequest ObjectCreateRequest = WebRequest.Create(uri);
427 ObjectCreateRequest.Method = "PUT";
428 ObjectCreateRequest.ContentType = "application/json";
429 ObjectCreateRequest.Timeout = 10000;
430
431 OSDMap args = new OSDMap(2);
432 args["userid"] = OSD.FromUUID(userID);
433 args["itemid"] = OSD.FromUUID(itemID);
434
435 string strBuffer = "";
436 byte[] buffer = new byte[1];
437 try
438 {
439 strBuffer = OSDParser.SerializeJsonString(args);
440 UTF8Encoding str = new UTF8Encoding();
441 buffer = str.GetBytes(strBuffer);
442
443 }
444 catch (Exception e)
445 {
446 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message);
447 // ignore. buffer will be empty, caller should check.
448 }
449
450 Stream os = null;
451 try
452 { // send the Post
453 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
454 os = ObjectCreateRequest.GetRequestStream();
455 os.Write(buffer, 0, strBuffer.Length); //Send it
456 os.Close();
457 //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri);
458 }
459 //catch (WebException ex)
460 catch
461 {
462 // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message);
463
464 return false;
465 }
466
467 // Let's wait for the response
468 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
469
470 try
471 {
472 WebResponse webResponse = ObjectCreateRequest.GetResponse();
473 if (webResponse == null)
474 {
475 m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post");
476 }
477
478 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
479 sr.ReadToEnd().Trim();
480 sr.ReadToEnd().Trim();
481 sr.Close();
482
483 //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply);
484
485 }
486 catch (WebException ex)
487 {
488 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message);
489 // ignore, really
490 }
491
492 return true;
493
494 }
495
420 public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) 496 public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion)
421 { 497 {
422 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; 498 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/";
diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs
index abb9b92..a3234bf 100644
--- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs
+++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs
@@ -107,6 +107,17 @@ namespace OpenSim.Framework.Communications.Services
107 public virtual void AddHttpHandlers() 107 public virtual void AddHttpHandlers()
108 { 108 {
109 httpServer.AddHTTPHandler("/InvCap/", CapHandler); 109 httpServer.AddHTTPHandler("/InvCap/", CapHandler);
110
111 // Un-cap'ed for now
112 httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryItemBase>(
113 "POST", "/GetItem/", GetInventoryItem, CheckAuthSession));
114
115 }
116
117 public InventoryItemBase GetInventoryItem(Guid id)
118 {
119 UUID itemID = new UUID(id);
120 return m_inventoryService.GetInventoryItem(itemID);
110 } 121 }
111 122
112 public bool CheckAuthSession(string session_id, string avatar_id) 123 public bool CheckAuthSession(string session_id, string avatar_id)
@@ -353,10 +364,15 @@ namespace OpenSim.Framework.Communications.Services
353 m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); 364 m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner);
354 return asset; 365 return asset;
355 } 366 }
367 UUID assetID = item2.AssetID;
368 if (assetID != item.AssetID)
369 {
370 m_log.WarnFormat("[HGStandaloneInvService]: asset IDs don't match {0}, {1}", item.AssetID, item2.AssetID);
371 }
356 372
357 // All good, get the asset 373 // All good, get the asset
358 //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); 374 //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID);
359 AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); 375 AssetBase theasset = FetchAsset(assetID, (item.InvType == (int)InventoryType.Texture));
360 376
361 m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); 377 m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null"));
362 if (theasset != null) 378 if (theasset != null)