diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 232 |
1 files changed, 0 insertions, 232 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs deleted file mode 100644 index adfbbad..0000000 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
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 OpenSim 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.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Framework.Communications.Cache; | ||
34 | |||
35 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Manage asset transactions for a single agent. | ||
39 | /// </summary> | ||
40 | public class AgentAssetTransactions | ||
41 | { | ||
42 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | // Fields | ||
45 | private bool m_dumpAssetsToFile; | ||
46 | public AssetTransactionModule Manager; | ||
47 | public UUID UserID; | ||
48 | public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); | ||
49 | |||
50 | // Methods | ||
51 | public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) | ||
52 | { | ||
53 | UserID = agentID; | ||
54 | Manager = manager; | ||
55 | m_dumpAssetsToFile = dumpAssetsToFile; | ||
56 | } | ||
57 | |||
58 | public AssetXferUploader RequestXferUploader(UUID transactionID) | ||
59 | { | ||
60 | if (!XferUploaders.ContainsKey(transactionID)) | ||
61 | { | ||
62 | AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); | ||
63 | |||
64 | lock (XferUploaders) | ||
65 | { | ||
66 | XferUploaders.Add(transactionID, uploader); | ||
67 | } | ||
68 | |||
69 | return uploader; | ||
70 | } | ||
71 | return null; | ||
72 | } | ||
73 | |||
74 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | ||
75 | { | ||
76 | lock (XferUploaders) | ||
77 | { | ||
78 | foreach (AssetXferUploader uploader in XferUploaders.Values) | ||
79 | { | ||
80 | if (uploader.XferID == xferID) | ||
81 | { | ||
82 | uploader.HandleXferPacket(xferID, packetID, data); | ||
83 | break; | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, | ||
90 | uint callbackID, string description, string name, sbyte invType, | ||
91 | sbyte type, byte wearableType, uint nextOwnerMask) | ||
92 | { | ||
93 | if (XferUploaders.ContainsKey(transactionID)) | ||
94 | { | ||
95 | XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, | ||
96 | callbackID, description, name, invType, type, | ||
97 | wearableType, nextOwnerMask); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | |||
102 | |||
103 | /// <summary> | ||
104 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. | ||
105 | /// </summary> | ||
106 | /// <param name="transactionID"></param> | ||
107 | /// <returns>The asset if the upload has completed, null if it has not.</returns> | ||
108 | public AssetBase GetTransactionAsset(UUID transactionID) | ||
109 | { | ||
110 | if (XferUploaders.ContainsKey(transactionID)) | ||
111 | { | ||
112 | AssetXferUploader uploader = XferUploaders[transactionID]; | ||
113 | AssetBase asset = uploader.GetAssetData(); | ||
114 | |||
115 | lock (XferUploaders) | ||
116 | { | ||
117 | XferUploaders.Remove(transactionID); | ||
118 | } | ||
119 | |||
120 | return asset; | ||
121 | } | ||
122 | |||
123 | return null; | ||
124 | } | ||
125 | |||
126 | //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) | ||
127 | //{ | ||
128 | // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); | ||
129 | // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | ||
130 | // ourClient.AgentId); | ||
131 | |||
132 | // if (userInfo != null) | ||
133 | // { | ||
134 | // InventoryItemBase item = new InventoryItemBase(); | ||
135 | // item.Owner = ourClient.AgentId; | ||
136 | // item.Creator = ourClient.AgentId; | ||
137 | // item.ID = UUID.Random(); | ||
138 | // item.AssetID = asset.FullID; | ||
139 | // item.Description = asset.Description; | ||
140 | // item.Name = asset.Name; | ||
141 | // item.AssetType = asset.Type; | ||
142 | // item.InvType = asset.Type; | ||
143 | // item.Folder = inventoryFolderID; | ||
144 | // item.BasePermissions = 0x7fffffff; | ||
145 | // item.CurrentPermissions = 0x7fffffff; | ||
146 | // item.EveryOnePermissions = 0; | ||
147 | // item.NextPermissions = nextPerms; | ||
148 | // item.Flags = wearableType; | ||
149 | // item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
150 | |||
151 | // userInfo.AddItem(item); | ||
152 | // ourClient.SendInventoryItemCreateUpdate(item); | ||
153 | // } | ||
154 | // else | ||
155 | // { | ||
156 | // m_log.ErrorFormat( | ||
157 | // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", | ||
158 | // ourClient.AgentId); | ||
159 | // } | ||
160 | //} | ||
161 | |||
162 | public void RequestUpdateTaskInventoryItem( | ||
163 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) | ||
164 | { | ||
165 | if (XferUploaders.ContainsKey(transactionID)) | ||
166 | { | ||
167 | AssetBase asset = XferUploaders[transactionID].GetAssetData(); | ||
168 | if (asset != null) | ||
169 | { | ||
170 | m_log.DebugFormat( | ||
171 | "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", | ||
172 | item.Name, part.Name, transactionID); | ||
173 | |||
174 | asset.Metadata.Name = item.Name; | ||
175 | asset.Metadata.Description = item.Description; | ||
176 | asset.Metadata.Type = (sbyte)item.Type; | ||
177 | item.AssetID = asset.Metadata.FullID; | ||
178 | |||
179 | Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); | ||
180 | |||
181 | if (part.Inventory.UpdateInventoryItem(item)) | ||
182 | part.GetProperties(remoteClient); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | |||
187 | |||
188 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, | ||
189 | InventoryItemBase item) | ||
190 | { | ||
191 | if (XferUploaders.ContainsKey(transactionID)) | ||
192 | { | ||
193 | CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | ||
194 | remoteClient.AgentId); | ||
195 | |||
196 | if (userInfo != null) | ||
197 | { | ||
198 | UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); | ||
199 | |||
200 | AssetBase asset | ||
201 | = Manager.MyScene.CommsManager.AssetCache.GetAsset( | ||
202 | assetID, (item.AssetType == (int)AssetType.Texture ? true : false)); | ||
203 | |||
204 | if (asset == null) | ||
205 | { | ||
206 | asset = GetTransactionAsset(transactionID); | ||
207 | } | ||
208 | |||
209 | if (asset != null && asset.Metadata.FullID == assetID) | ||
210 | { | ||
211 | // Assets never get updated, new ones get created | ||
212 | asset.Metadata.FullID = UUID.Random(); | ||
213 | asset.Metadata.Name = item.Name; | ||
214 | asset.Metadata.Description = item.Description; | ||
215 | asset.Metadata.Type = (sbyte)item.AssetType; | ||
216 | item.AssetID = asset.Metadata.FullID; | ||
217 | |||
218 | Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); | ||
219 | } | ||
220 | |||
221 | userInfo.UpdateItem(item); | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | m_log.ErrorFormat( | ||
226 | "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item update", | ||
227 | remoteClient.AgentId); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | } | ||