diff options
author | Dan Lake | 2012-02-01 16:25:35 -0800 |
---|---|---|
committer | Dan Lake | 2012-02-01 16:25:35 -0800 |
commit | c10193c72b1f029a958f04d2f5d7ee384e693aaa (patch) | |
tree | 052ec7e973c15b158310511197affad14eb9c64f /OpenSim/Region/ClientStack/Linden/Caps | |
parent | Trigger event when prims are scheduled for an update. This gives modules earl... (diff) | |
parent | Small optimization to last commit (diff) | |
download | opensim-SC-c10193c72b1f029a958f04d2f5d7ee384e693aaa.zip opensim-SC-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.gz opensim-SC-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.bz2 opensim-SC-c10193c72b1f029a958f04d2f5d7ee384e693aaa.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
3 files changed, 226 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 2347cf2..cf0c28b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -94,6 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
94 | private static readonly string m_notecardUpdatePath = "0004/"; | 94 | private static readonly string m_notecardUpdatePath = "0004/"; |
95 | private static readonly string m_notecardTaskUpdatePath = "0005/"; | 95 | private static readonly string m_notecardTaskUpdatePath = "0005/"; |
96 | // private static readonly string m_fetchInventoryPath = "0006/"; | 96 | // private static readonly string m_fetchInventoryPath = "0006/"; |
97 | private static readonly string m_copyFromNotecardPath = "0007/"; | ||
97 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. | 98 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. |
98 | 99 | ||
99 | 100 | ||
@@ -180,6 +181,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
180 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); | 181 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); |
181 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); | 182 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); |
182 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); | 183 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); |
184 | m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard)); | ||
183 | 185 | ||
184 | // As of RC 1.22.9 of the Linden client this is | 186 | // As of RC 1.22.9 of the Linden client this is |
185 | // supported | 187 | // supported |
@@ -366,7 +368,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
366 | 368 | ||
367 | if (mm != null) | 369 | if (mm != null) |
368 | { | 370 | { |
369 | if (!mm.UploadCovered(client, mm.UploadCharge)) | 371 | if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) |
370 | { | 372 | { |
371 | if (client != null) | 373 | if (client != null) |
372 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | 374 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); |
@@ -723,6 +725,75 @@ namespace OpenSim.Region.ClientStack.Linden | |||
723 | 725 | ||
724 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | 726 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); |
725 | } | 727 | } |
728 | |||
729 | /// <summary> | ||
730 | /// Called by the CopyInventoryFromNotecard caps handler. | ||
731 | /// </summary> | ||
732 | /// <param name="request"></param> | ||
733 | /// <param name="path"></param> | ||
734 | /// <param name="param"></param> | ||
735 | public string CopyInventoryFromNotecard(string request, string path, string param, | ||
736 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
737 | { | ||
738 | Hashtable response = new Hashtable(); | ||
739 | response["int_response_code"] = 404; | ||
740 | response["content_type"] = "text/plain"; | ||
741 | response["keepalive"] = false; | ||
742 | response["str_response_string"] = ""; | ||
743 | |||
744 | try | ||
745 | { | ||
746 | OSDMap content = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
747 | UUID objectID = content["object-id"].AsUUID(); | ||
748 | UUID notecardID = content["notecard-id"].AsUUID(); | ||
749 | UUID folderID = content["folder-id"].AsUUID(); | ||
750 | UUID itemID = content["item-id"].AsUUID(); | ||
751 | |||
752 | // m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, FolderID:{0}, ItemID:{1}, NotecardID:{2}, ObjectID:{3}", folderID, itemID, notecardID, objectID); | ||
753 | |||
754 | if (objectID != UUID.Zero) | ||
755 | { | ||
756 | SceneObjectPart part = m_Scene.GetSceneObjectPart(objectID); | ||
757 | if (part != null) | ||
758 | { | ||
759 | TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(notecardID); | ||
760 | if (!m_Scene.Permissions.CanCopyObjectInventory(notecardID, objectID, m_HostCapsObj.AgentID)) | ||
761 | { | ||
762 | return LLSDHelpers.SerialiseLLSDReply(response); | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | |||
767 | InventoryItemBase item = null; | ||
768 | InventoryItemBase copyItem = null; | ||
769 | IClientAPI client = null; | ||
770 | |||
771 | m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); | ||
772 | item = m_Scene.InventoryService.GetItem(new InventoryItemBase(itemID)); | ||
773 | if (item != null) | ||
774 | { | ||
775 | copyItem = m_Scene.GiveInventoryItem(m_HostCapsObj.AgentID, item.Owner, itemID, folderID); | ||
776 | if (copyItem != null && client != null) | ||
777 | { | ||
778 | m_log.InfoFormat("[CAPS]: CopyInventoryFromNotecard, ItemID:{0}, FolderID:{1}", copyItem.ID, copyItem.Folder); | ||
779 | client.SendBulkUpdateInventory(copyItem); | ||
780 | } | ||
781 | } | ||
782 | else | ||
783 | { | ||
784 | m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard - Failed to retrieve item {0} from notecard {1}", itemID, notecardID); | ||
785 | if (client != null) | ||
786 | client.SendAlertMessage("Failed to retrieve item"); | ||
787 | } | ||
788 | } | ||
789 | catch (Exception e) | ||
790 | { | ||
791 | m_log.ErrorFormat("[CAPS]: CopyInventoryFromNotecard : {0}", e.ToString()); | ||
792 | } | ||
793 | |||
794 | response["int_response_code"] = 200; | ||
795 | return LLSDHelpers.SerialiseLLSDReply(response); | ||
796 | } | ||
726 | } | 797 | } |
727 | 798 | ||
728 | public class AssetUploader | 799 | public class AssetUploader |
@@ -1018,4 +1089,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1018 | fs.Close(); | 1089 | fs.Close(); |
1019 | } | 1090 | } |
1020 | } | 1091 | } |
1021 | } \ No newline at end of file | 1092 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs new file mode 100644 index 0000000..14501c7 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs | |||
@@ -0,0 +1,151 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using Mono.Addins; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
41 | using OpenSim.Capabilities.Handlers; | ||
42 | |||
43 | namespace OpenSim.Region.ClientStack.Linden | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. | ||
47 | /// </summary> | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
49 | public class FetchInventory2Module : INonSharedRegionModule | ||
50 | { | ||
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | public bool Enabled { get; private set; } | ||
54 | |||
55 | private Scene m_scene; | ||
56 | |||
57 | private IInventoryService m_inventoryService; | ||
58 | |||
59 | private string m_fetchInventory2Url; | ||
60 | |||
61 | private FetchInventory2Handler m_fetchHandler; | ||
62 | |||
63 | #region ISharedRegionModule Members | ||
64 | |||
65 | public void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
68 | if (config == null) | ||
69 | return; | ||
70 | |||
71 | m_fetchInventory2Url = config.GetString("Cap_FetchInventory2", string.Empty); | ||
72 | |||
73 | if (m_fetchInventory2Url != string.Empty) | ||
74 | Enabled = true; | ||
75 | } | ||
76 | |||
77 | public void AddRegion(Scene s) | ||
78 | { | ||
79 | if (!Enabled) | ||
80 | return; | ||
81 | |||
82 | m_scene = s; | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene s) | ||
86 | { | ||
87 | if (!Enabled) | ||
88 | return; | ||
89 | |||
90 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
91 | m_scene = null; | ||
92 | } | ||
93 | |||
94 | public void RegionLoaded(Scene s) | ||
95 | { | ||
96 | if (!Enabled) | ||
97 | return; | ||
98 | |||
99 | m_inventoryService = m_scene.InventoryService; | ||
100 | |||
101 | // We'll reuse the same handler for all requests. | ||
102 | if (m_fetchInventory2Url == "localhost") | ||
103 | m_fetchHandler = new FetchInventory2Handler(m_inventoryService); | ||
104 | |||
105 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | ||
106 | } | ||
107 | |||
108 | public void PostInitialise() {} | ||
109 | |||
110 | public void Close() {} | ||
111 | |||
112 | public string Name { get { return "FetchInventory2Module"; } } | ||
113 | |||
114 | public Type ReplaceableInterface | ||
115 | { | ||
116 | get { return null; } | ||
117 | } | ||
118 | |||
119 | #endregion | ||
120 | |||
121 | private void RegisterCaps(UUID agentID, Caps caps) | ||
122 | { | ||
123 | RegisterFetchCap(agentID, caps, "FetchInventory2", m_fetchInventory2Url); | ||
124 | } | ||
125 | |||
126 | private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) | ||
127 | { | ||
128 | string capUrl; | ||
129 | |||
130 | if (url == "localhost") | ||
131 | { | ||
132 | capUrl = "/CAPS/" + UUID.Random(); | ||
133 | |||
134 | IRequestHandler reqHandler | ||
135 | = new RestStreamHandler("POST", capUrl, m_fetchHandler.FetchInventoryRequest); | ||
136 | |||
137 | caps.RegisterHandler(capName, reqHandler); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | capUrl = url; | ||
142 | |||
143 | caps.RegisterHandler(capName, capUrl); | ||
144 | } | ||
145 | |||
146 | // m_log.DebugFormat( | ||
147 | // "[FETCH INVENTORY2 MODULE]: Registered capability {0} at {1} in region {2} for {3}", | ||
148 | // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); | ||
149 | } | ||
150 | } | ||
151 | } | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index b2f04f9..aed03b3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -147,7 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
147 | { | 147 | { |
148 | if (m_scene.TryGetClient(agentID, out client)) | 148 | if (m_scene.TryGetClient(agentID, out client)) |
149 | { | 149 | { |
150 | if (!mm.UploadCovered(client, mm.UploadCharge)) | 150 | if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) |
151 | { | 151 | { |
152 | if (client != null) | 152 | if (client != null) |
153 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | 153 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); |
@@ -268,4 +268,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
268 | 268 | ||
269 | } | 269 | } |
270 | } | 270 | } |
271 | } \ No newline at end of file | 271 | } |