aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordiva2009-04-05 03:27:50 +0000
committerdiva2009-04-05 03:27:50 +0000
commit3c9cba162739b93a07067d8a286f6dad55e02217 (patch)
treec4f9054f524b002b37e4d36a382c206b028f25d9 /OpenSim
parent* Fixed copyright headers on HyperGrid source files. (Now match the rest of O... (diff)
downloadopensim-SC-3c9cba162739b93a07067d8a286f6dad55e02217.zip
opensim-SC-3c9cba162739b93a07067d8a286f6dad55e02217.tar.gz
opensim-SC-3c9cba162739b93a07067d8a286f6dad55e02217.tar.bz2
opensim-SC-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 'OpenSim')
-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
-rw-r--r--OpenSim/Grid/InventoryServer/Main.cs74
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs11
-rw-r--r--OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs13
-rw-r--r--OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs53
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs42
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInterregionComms.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs66
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs11
12 files changed, 381 insertions, 78 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)
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 07fb19c..70efb85 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -76,8 +76,8 @@ namespace OpenSim.Grid.InventoryServer
76 m_log.Info("[" + LogName + "]: Starting HTTP server ..."); 76 m_log.Info("[" + LogName + "]: Starting HTTP server ...");
77 77
78 m_httpServer = new BaseHttpServer(config.HttpPort); 78 m_httpServer = new BaseHttpServer(config.HttpPort);
79 if (config.RegionAccessToAgentsInventory) 79
80 AddHttpHandlers(); 80 AddHttpHandlers(config.RegionAccessToAgentsInventory);
81 81
82 m_httpServer.Start(); 82 m_httpServer.Start();
83 83
@@ -92,55 +92,64 @@ namespace OpenSim.Grid.InventoryServer
92 "Add a random user inventory", HandleAddUser); 92 "Add a random user inventory", HandleAddUser);
93 } 93 }
94 94
95 protected void AddHttpHandlers() 95 protected void AddHttpHandlers(bool regionAccess)
96 { 96 {
97 m_httpServer.AddStreamHandler( 97 if (regionAccess)
98 new RestDeserialiseSecureHandler<Guid, InventoryCollection>( 98 {
99 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession)); 99 m_httpServer.AddStreamHandler(
100 new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
101 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, m_inventoryService.CheckAuthSession));
100 102
101 m_httpServer.AddStreamHandler( 103 m_httpServer.AddStreamHandler(
102 new RestDeserialiseTrustedHandler<Guid, bool>( 104 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
103 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource)); 105 "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession));
104 106
105 m_httpServer.AddStreamHandler( 107 m_httpServer.AddStreamHandler(
106 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 108 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
107 "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession)); 109 "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession));
108 110
109 m_httpServer.AddStreamHandler( 111 m_httpServer.AddStreamHandler(
110 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 112 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
111 "POST", "/UpdateFolder/", m_inventoryService.UpdateFolder, m_inventoryService.CheckAuthSession)); 113 "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession));
114
115 m_httpServer.AddStreamHandler(
116 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
117 "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession));
118
119 m_httpServer.AddStreamHandler(
120 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
121 "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession));
122
123 m_httpServer.AddStreamHandler(
124 new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>(
125 "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession));
126
127 }
112 128
113 m_httpServer.AddStreamHandler( 129 m_httpServer.AddStreamHandler(
114 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 130 new RestDeserialiseTrustedHandler<Guid, bool>(
115 "POST", "/MoveFolder/", m_inventoryService.MoveFolder, m_inventoryService.CheckAuthSession)); 131 "POST", "/CreateInventory/", m_inventoryService.CreateUsersInventory, m_inventoryService.CheckTrustSource));
116 132
117 m_httpServer.AddStreamHandler( 133 m_httpServer.AddStreamHandler(
118 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 134 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
119 "POST", "/PurgeFolder/", m_inventoryService.PurgeFolder, m_inventoryService.CheckAuthSession)); 135 "POST", "/NewFolder/", m_inventoryService.AddFolder, m_inventoryService.CheckAuthSession));
120 136
121 m_httpServer.AddStreamHandler( 137 m_httpServer.AddStreamHandler(
122 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 138 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
123 "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession)); 139 "POST", "/NewItem/", m_inventoryService.AddItem, m_inventoryService.CheckAuthSession));
124 140
125 m_httpServer.AddStreamHandler( 141 m_httpServer.AddStreamHandler(
126 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>(
127 "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource));
128
129 m_httpServer.AddStreamHandler(
130 new RestDeserialiseTrustedHandler<InventoryItemBase, bool>( 142 new RestDeserialiseTrustedHandler<InventoryItemBase, bool>(
131 "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource)); 143 "POST", "/AddNewItem/", m_inventoryService.AddItem, m_inventoryService.CheckTrustSource));
132 144
133 m_httpServer.AddStreamHandler( 145 m_httpServer.AddStreamHandler(
134 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 146 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>(
135 "POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession)); 147 "POST", "/GetItems/", m_inventoryService.GetFolderItems, m_inventoryService.CheckTrustSource));
136
137 m_httpServer.AddStreamHandler(
138 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
139 "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession));
140 148
149 // for persistent active gestures
141 m_httpServer.AddStreamHandler( 150 m_httpServer.AddStreamHandler(
142 new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryFolderBase>( 151 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
143 "POST", "/QueryFolder/", m_inventoryService.QueryFolder, m_inventoryService.CheckAuthSession)); 152 ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource));
144 153
145 // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g 154 // WARNING: Root folders no longer just delivers the root and immediate child folders (e.g
146 // system folders such as Objects, Textures), but it now returns the entire inventory skeleton. 155 // system folders such as Objects, Textures), but it now returns the entire inventory skeleton.
@@ -150,11 +159,6 @@ namespace OpenSim.Grid.InventoryServer
150 m_httpServer.AddStreamHandler( 159 m_httpServer.AddStreamHandler(
151 new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> 160 new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>>
152 ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource)); 161 ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton, m_inventoryService.CheckTrustSource));
153
154 // for persistent active gestures
155 m_httpServer.AddStreamHandler(
156 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
157 ("POST", "/ActiveGestures/", m_inventoryService.GetActiveGestures, m_inventoryService.CheckTrustSource));
158 } 162 }
159 163
160 private void Work() 164 private void Work()
diff --git a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
index 2e402a4..a2b2c84 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGInventoryService.cs
@@ -113,6 +113,17 @@ namespace OpenSim.Region.Communications.Hypergrid
113 113
114 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Request inventory operation failed, {0} {1}", 114 m_log.ErrorFormat("[HGrid INVENTORY SERVICE]: Request inventory operation failed, {0} {1}",
115 e.Source, e.Message); 115 e.Source, e.Message);
116
117 // Well, let's synthesize one
118 InventoryCollection icol = new InventoryCollection();
119 icol.UserID = userID;
120 icol.Items = new List<InventoryItemBase>();
121 icol.Folders = new List<InventoryFolderBase>();
122 InventoryFolderBase rootFolder = new InventoryFolderBase();
123 rootFolder.ID = UUID.Random();
124 rootFolder.Owner = userID;
125 icol.Folders.Add(rootFolder);
126 InventoryResponse(icol);
116 } 127 }
117 } 128 }
118 else 129 else
diff --git a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs
index fb293e8..1e430e5 100644
--- a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs
@@ -244,6 +244,19 @@ namespace OpenSim.Region.CoreModules.Communications.Local
244 return false; 244 return false;
245 } 245 }
246 246
247 public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID)
248 {
249 foreach (Scene s in m_sceneList)
250 {
251 if (s.RegionInfo.RegionHandle == regionHandle)
252 {
253 return s.IncomingCreateObject(userID, itemID);
254 }
255 }
256 return false;
257 }
258
259
247 /** 260 /**
248 * Region-related communications 261 * Region-related communications
249 */ 262 */
diff --git a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs
index b507bdd..90104f2 100644
--- a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs
@@ -276,6 +276,12 @@ namespace OpenSim.Region.CoreModules.Communications.REST
276 return false; 276 return false;
277 } 277 }
278 278
279 public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID)
280 {
281 // Not Implemented
282 return false;
283 }
284
279 /** 285 /**
280 * Region-related communications 286 * Region-related communications
281 */ 287 */
@@ -527,13 +533,13 @@ namespace OpenSim.Region.CoreModules.Communications.REST
527 533
528 public Hashtable ObjectHandler(Hashtable request) 534 public Hashtable ObjectHandler(Hashtable request)
529 { 535 {
530 //m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); 536 m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
531 537
532 //m_log.Debug("---------------------------"); 538 m_log.Debug("---------------------------");
533 //m_log.Debug(" >> uri=" + request["uri"]); 539 m_log.Debug(" >> uri=" + request["uri"]);
534 //m_log.Debug(" >> content-type=" + request["content-type"]); 540 m_log.Debug(" >> content-type=" + request["content-type"]);
535 //m_log.Debug(" >> http-method=" + request["http-method"]); 541 m_log.Debug(" >> http-method=" + request["http-method"]);
536 //m_log.Debug("---------------------------\n"); 542 m_log.Debug("---------------------------\n");
537 543
538 Hashtable responsedata = new Hashtable(); 544 Hashtable responsedata = new Hashtable();
539 responsedata["content_type"] = "text/html"; 545 responsedata["content_type"] = "text/html";
@@ -557,11 +563,11 @@ namespace OpenSim.Region.CoreModules.Communications.REST
557 DoObjectPost(request, responsedata, regionHandle); 563 DoObjectPost(request, responsedata, regionHandle);
558 return responsedata; 564 return responsedata;
559 } 565 }
560 //else if (method.Equals("PUT")) 566 else if (method.Equals("PUT"))
561 //{ 567 {
562 // DoObjectPut(request, responsedata, agentID); 568 DoObjectPut(request, responsedata, regionHandle);
563 // return responsedata; 569 return responsedata;
564 //} 570 }
565 //else if (method.Equals("DELETE")) 571 //else if (method.Equals("DELETE"))
566 //{ 572 //{
567 // DoObjectDelete(request, responsedata, agentID, action, regionHandle); 573 // DoObjectDelete(request, responsedata, agentID, action, regionHandle);
@@ -632,6 +638,31 @@ namespace OpenSim.Region.CoreModules.Communications.REST
632 responsedata["str_response_string"] = result.ToString(); 638 responsedata["str_response_string"] = result.ToString();
633 } 639 }
634 640
641 protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle)
642 {
643 OSDMap args = RegionClient.GetOSDMap((string)request["body"]);
644 if (args == null)
645 {
646 responsedata["int_response_code"] = 400;
647 responsedata["str_response_string"] = "false";
648 return;
649 }
650
651 UUID userID = UUID.Zero, itemID = UUID.Zero;
652 if (args["userid"] != null)
653 userID = args["userid"].AsUUID();
654 if (args["itemid"] != null)
655 itemID = args["itemid"].AsUUID();
656
657 UUID regionID = m_localBackend.GetRegionID(regionhandle);
658
659 // This is the meaning of PUT object
660 bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID);
661
662 responsedata["int_response_code"] = 200;
663 responsedata["str_response_string"] = result.ToString();
664 }
665
635 /* 666 /*
636 * Region-related incoming calls 667 * Region-related incoming calls
637 * 668 *
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
index 741075c..3675583 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
@@ -54,6 +54,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private static bool initialized = false; 55 private static bool initialized = false;
56 private static bool enabled = false; 56 private static bool enabled = false;
57 private static bool safemode = false;
57 58
58 private bool m_doLookup = false; 59 private bool m_doLookup = false;
59 Scene m_scene; 60 Scene m_scene;
@@ -77,6 +78,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid
77 78
78 // This module is only on for standalones 79 // This module is only on for standalones
79 enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); 80 enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false);
81 if (config.Configs["Hypergrid"] != null)
82 safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false);
80 } 83 }
81 } 84 }
82 85
@@ -116,34 +119,35 @@ namespace OpenSim.Region.CoreModules.Hypergrid
116 119
117 public virtual void AddHttpHandlers(IHttpServer httpServer) 120 public virtual void AddHttpHandlers(IHttpServer httpServer)
118 { 121 {
119 122 if (!safemode)
120 httpServer.AddStreamHandler( 123 {
121 new RestDeserialiseSecureHandler<Guid, InventoryCollection>( 124 httpServer.AddStreamHandler(
122 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); 125 new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
126 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession));
127 httpServer.AddStreamHandler(
128 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
129 "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession));
130 httpServer.AddStreamHandler(
131 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
132 "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession));
133
134 httpServer.AddStreamHandler(
135 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
136 "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession));
137
138 httpServer.AddStreamHandler(
139 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
140 "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession));
141 }
123 142
124 httpServer.AddStreamHandler( 143 httpServer.AddStreamHandler(
125 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 144 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
126 "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession)); 145 "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession));
127 146
128 httpServer.AddStreamHandler( 147 httpServer.AddStreamHandler(
129 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
130 "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession));
131
132 httpServer.AddStreamHandler(
133 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
134 "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession));
135
136 httpServer.AddStreamHandler(
137 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
138 "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession));
139
140 httpServer.AddStreamHandler(
141 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 148 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
142 "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession)); 149 "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession));
143 150
144 httpServer.AddStreamHandler(
145 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
146 "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession));
147 151
148 } 152 }
149 153
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
index ef3cb51..b57b5ed 100644
--- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
@@ -89,6 +89,16 @@ namespace OpenSim.Region.Framework.Interfaces
89 /// <returns></returns> 89 /// <returns></returns>
90 bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); 90 bool SendCreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall);
91 91
92 /// <summary>
93 /// Create an object from the user's inventory in the destination region.
94 /// This message is used primarily for prim crossing.
95 /// </summary>
96 /// <param name="regionHandle"></param>
97 /// <param name="sog"></param>
98 /// <param name="isLocalCall"></param>
99 /// <returns></returns>
100 bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID);
101
92 #endregion Objects 102 #endregion Objects
93 103
94 #region Regions 104 #region Regions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index e9106e5..b192101 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -33,6 +33,7 @@ using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
36 37
37//using HyperGrid.Framework; 38//using HyperGrid.Framework;
38//using OpenSim.Region.Communications.Hypergrid; 39//using OpenSim.Region.Communications.Hypergrid;
@@ -50,6 +51,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50 // This maps between asset UUIDs and asset servers 51 // This maps between asset UUIDs and asset servers
51 private Dictionary<UUID, GridAssetClient> m_assetMap = new Dictionary<UUID, GridAssetClient>(); 52 private Dictionary<UUID, GridAssetClient> m_assetMap = new Dictionary<UUID, GridAssetClient>();
52 53
54 // This maps between inventory server urls and inventory server clients
55 private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
56
57
53 private Scene m_scene; 58 private Scene m_scene;
54 #endregion 59 #endregion
55 60
@@ -72,6 +77,14 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
72 return null; 77 return null;
73 } 78 }
74 79
80 private string UserInventoryURL(UUID userID)
81 {
82 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83 if (uinfo != null)
84 return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
85 return null;
86 }
87
75 private bool IsLocalUser(UUID userID) 88 private bool IsLocalUser(UUID userID)
76 { 89 {
77 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); 90 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
@@ -275,9 +288,9 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
275 288
276 #region Public interface 289 #region Public interface
277 290
278 public void Get(UUID itemID, UUID ownerID) 291 public void Get(UUID assetID, UUID ownerID)
279 { 292 {
280 if (!IsInAssetMap(itemID) && !IsLocalUser(ownerID)) 293 if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID))
281 { 294 {
282 // Get the item from the remote asset server onto the local AssetCache 295 // Get the item from the remote asset server onto the local AssetCache
283 // and place an entry in m_assetMap 296 // and place an entry in m_assetMap
@@ -295,11 +308,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
295 m_assetServers.Add(userAssetURL, asscli); 308 m_assetServers.Add(userAssetURL, asscli);
296 } 309 }
297 310
298 m_log.Debug("[HGScene]: Fetching object " + itemID + " to asset server " + userAssetURL); 311 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
299 bool success = FetchAsset(asscli, itemID, false); // asscli.RequestAsset(item.ItemID, false); 312 bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false);
300 313
301 // OK, now fetch the inside. 314 // OK, now fetch the inside.
302 Dictionary<UUID, bool> ids = SniffUUIDs(itemID); 315 Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
303 Dump(ids); 316 Dump(ids);
304 foreach (KeyValuePair<UUID, bool> kvp in ids) 317 foreach (KeyValuePair<UUID, bool> kvp in ids)
305 FetchAsset(asscli, kvp.Key, kvp.Value); 318 FetchAsset(asscli, kvp.Key, kvp.Value);
@@ -308,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
308 if (success) 321 if (success)
309 { 322 {
310 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); 323 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
311 m_assetMap.Add(itemID, asscli); 324 m_assetMap.Add(assetID, asscli);
312 } 325 }
313 else 326 else
314 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); 327 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
@@ -318,7 +331,36 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
318 } 331 }
319 } 332 }
320 333
321 public void Post(UUID itemID, UUID ownerID) 334 public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
335 {
336 if (!IsLocalUser(item.Owner))
337 {
338 InventoryClient invCli = null;
339 string inventoryURL = UserInventoryURL(item.Owner);
340 if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
341 {
342 m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
343 invCli = new InventoryClient(inventoryURL);
344 m_inventoryServers.Add(inventoryURL, invCli);
345 }
346
347 item = invCli.GetInventoryItem(item);
348 if (item != null)
349 {
350 // Change the folder, stick it in root folder, all items flattened out here in this region cache
351 item.Folder = rootFolder;
352 //userInfo.AddItem(item); don't use this, it calls back to the inventory server
353 lock (userInfo.RootFolder.Items)
354 {
355 userInfo.RootFolder.Items[item.ID] = item;
356 }
357
358 }
359 }
360 return item;
361 }
362
363 public void Post(UUID assetID, UUID ownerID)
322 { 364 {
323 if (!IsLocalUser(ownerID)) 365 if (!IsLocalUser(ownerID))
324 { 366 {
@@ -337,11 +379,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
337 asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! 379 asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache!
338 m_assetServers.Add(userAssetURL, asscli); 380 m_assetServers.Add(userAssetURL, asscli);
339 } 381 }
340 m_log.Debug("[HGScene]: Posting object " + itemID + " to asset server " + userAssetURL); 382 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
341 bool success = PostAsset(asscli, itemID); 383 bool success = PostAsset(asscli, assetID);
342 384
343 // Now the inside 385 // Now the inside
344 Dictionary<UUID, bool> ids = SniffUUIDs(itemID); 386 Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
345 Dump(ids); 387 Dump(ids);
346 foreach (KeyValuePair<UUID, bool> kvp in ids) 388 foreach (KeyValuePair<UUID, bool> kvp in ids)
347 PostAsset(asscli, kvp.Key); 389 PostAsset(asscli, kvp.Key);
@@ -349,8 +391,8 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
349 if (success) 391 if (success)
350 { 392 {
351 m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); 393 m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL);
352 if (!m_assetMap.ContainsKey(itemID)) 394 if (!m_assetMap.ContainsKey(assetID))
353 m_assetMap.Add(itemID, asscli); 395 m_assetMap.Add(assetID, asscli);
354 } 396 }
355 else 397 else
356 m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); 398 m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL);
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
index 93b81e0..4fde9bb 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -120,6 +120,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
120 { 120 {
121 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); 121 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
122 122
123 if (item == null)
124 { // Fetch the item
125 item = new InventoryItemBase();
126 item.Owner = remoteClient.AgentId;
127 item.ID = itemID;
128 item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
129 }
123 if (item != null) 130 if (item != null)
124 { 131 {
125 m_assMapper.Get(item.AssetID, remoteClient.AgentId); 132 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5f68ccb..30257f1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1731,6 +1731,17 @@ namespace OpenSim.Region.Framework.Scenes
1731 return true; 1731 return true;
1732 } 1732 }
1733 1733
1734 public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
1735 {
1736 ScenePresence sp = GetScenePresence(userID);
1737 if (sp != null)
1738 {
1739 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
1740 SceneObjectGroup sog = m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt);
1741 }
1742 return false;
1743 }
1744
1734 public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject) 1745 public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject)
1735 { 1746 {
1736 // If the user is banned, we won't let any of their objects 1747 // If the user is banned, we won't let any of their objects