diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs new file mode 100644 index 0000000..af3c04f --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs | |||
@@ -0,0 +1,152 @@ | |||
1 | /** | ||
2 | * Copyright (c) 2008, 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 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using System.Threading; | ||
34 | |||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Cache; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Region.Environment; | ||
44 | using OpenSim.Region.Environment.Scenes; | ||
45 | |||
46 | namespace OpenSim.Region.Environment.Scenes.Hypergrid | ||
47 | { | ||
48 | public partial class HGScene : Scene | ||
49 | { | ||
50 | #region Fields | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private HGAssetMapper m_assMapper; | ||
54 | |||
55 | #endregion | ||
56 | |||
57 | #region Constructors | ||
58 | |||
59 | public HGScene(RegionInfo regInfo, AgentCircuitManager authen, | ||
60 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | ||
61 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, | ||
62 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | ||
63 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | ||
64 | : base(regInfo, authen, commsMan, sceneGridService, assetCach, storeManager, httpServer, moduleLoader, | ||
65 | dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) | ||
66 | { | ||
67 | m_log.Info("[HGScene]: Starting HGScene."); | ||
68 | m_assMapper = new HGAssetMapper(this); | ||
69 | |||
70 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | ||
71 | } | ||
72 | |||
73 | #endregion | ||
74 | |||
75 | #region Event handlers | ||
76 | |||
77 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | ||
78 | { | ||
79 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); | ||
80 | if (userInfo != null) | ||
81 | { | ||
82 | m_assMapper.Post(assetID, avatarID); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | #endregion | ||
87 | |||
88 | #region Overrides of Scene.Inventory methods | ||
89 | |||
90 | /// | ||
91 | /// CapsUpdateInventoryItemAsset | ||
92 | /// | ||
93 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | ||
94 | { | ||
95 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | ||
96 | |||
97 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | ||
98 | |||
99 | return newAssetID; | ||
100 | } | ||
101 | |||
102 | /// | ||
103 | /// DeleteToInventory | ||
104 | /// | ||
105 | public override UUID DeleteToInventory(int destination, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
106 | { | ||
107 | UUID assetID = base.DeleteToInventory(destination, folderID, objectGroup, remoteClient); | ||
108 | |||
109 | if (!assetID.Equals(UUID.Zero)) | ||
110 | { | ||
111 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); | ||
112 | } | ||
113 | else | ||
114 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | ||
115 | |||
116 | return assetID; | ||
117 | } | ||
118 | |||
119 | /// | ||
120 | /// RezObject | ||
121 | /// | ||
122 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
123 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
124 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
125 | { | ||
126 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | ||
127 | if (userInfo != null) | ||
128 | { | ||
129 | if (userInfo.RootFolder != null) | ||
130 | { | ||
131 | InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); | ||
132 | |||
133 | if (item != null) | ||
134 | { | ||
135 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); | ||
136 | |||
137 | } | ||
138 | } | ||
139 | } | ||
140 | |||
141 | // OK, we're done fetching. Pass it up to the default RezObject | ||
142 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
143 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
144 | |||
145 | } | ||
146 | |||
147 | |||
148 | #endregion | ||
149 | |||
150 | } | ||
151 | |||
152 | } | ||