clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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.Collections.Generic; |
||
29 | using System.Reflection; |
||
30 | using log4net; |
||
31 | using OpenMetaverse; |
||
32 | using OpenSim.Framework; |
||
33 | |||
34 | using OpenSim.Region.Framework.Scenes; |
||
35 | using OpenSim.Services.Interfaces; |
||
36 | using OpenSim.Region.Framework.Interfaces; |
||
37 | |||
38 | namespace OpenSim.Region.CoreModules.Agent.AssetTransaction |
||
39 | { |
||
40 | /// <summary> |
||
41 | /// Manage asset transactions for a single agent. |
||
42 | /// </summary> |
||
43 | public class AgentAssetTransactions |
||
44 | { |
||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
46 | |||
47 | // Fields |
||
48 | private bool m_dumpAssetsToFile; |
||
49 | private Scene m_Scene; |
||
50 | private Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); |
||
51 | |||
52 | // Methods |
||
53 | public AgentAssetTransactions(UUID agentID, Scene scene, |
||
54 | bool dumpAssetsToFile) |
||
55 | { |
||
56 | m_Scene = scene; |
||
57 | m_dumpAssetsToFile = dumpAssetsToFile; |
||
58 | } |
||
59 | |||
60 | /// <summary> |
||
61 | /// Return the xfer uploader for the given transaction. |
||
62 | /// </summary> |
||
63 | /// <remarks> |
||
64 | /// If an uploader does not already exist for this transaction then it is created, otherwise the existing |
||
65 | /// uploader is returned. |
||
66 | /// </remarks> |
||
67 | /// <param name="transactionID"></param> |
||
68 | /// <returns>The asset xfer uploader</returns> |
||
69 | public AssetXferUploader RequestXferUploader(UUID transactionID) |
||
70 | { |
||
71 | AssetXferUploader uploader; |
||
72 | |||
73 | lock (XferUploaders) |
||
74 | { |
||
75 | if (!XferUploaders.ContainsKey(transactionID)) |
||
76 | { |
||
77 | uploader = new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile); |
||
78 | |||
79 | // m_log.DebugFormat( |
||
80 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); |
||
81 | |||
82 | XferUploaders.Add(transactionID, uploader); |
||
83 | } |
||
84 | else |
||
85 | { |
||
86 | uploader = XferUploaders[transactionID]; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | return uploader; |
||
91 | } |
||
92 | |||
93 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
||
94 | { |
||
95 | AssetXferUploader foundUploader = null; |
||
96 | |||
97 | lock (XferUploaders) |
||
98 | { |
||
99 | foreach (AssetXferUploader uploader in XferUploaders.Values) |
||
100 | { |
||
101 | // m_log.DebugFormat( |
||
102 | // "[AGENT ASSETS TRANSACTIONS]: In HandleXfer, inspect xfer upload with xfer id {0}", |
||
103 | // uploader.XferID); |
||
104 | |||
105 | if (uploader.XferID == xferID) |
||
106 | { |
||
107 | foundUploader = uploader; |
||
108 | break; |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 | |||
113 | if (foundUploader != null) |
||
114 | { |
||
115 | // m_log.DebugFormat( |
||
116 | // "[AGENT ASSETS TRANSACTIONS]: Found xfer uploader for xfer id {0}, packet id {1}, data length {2}", |
||
117 | // xferID, packetID, data.Length); |
||
118 | |||
119 | foundUploader.HandleXferPacket(xferID, packetID, data); |
||
120 | } |
||
121 | else |
||
122 | { |
||
123 | // Check if the xfer is a terrain xfer |
||
124 | IEstateModule estateModule = m_Scene.RequestModuleInterface<IEstateModule>(); |
||
125 | if (estateModule != null) |
||
126 | { |
||
127 | if (estateModule.IsTerrainXfer(xferID)) |
||
128 | return; |
||
129 | } |
||
130 | |||
131 | m_log.ErrorFormat( |
||
132 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}", |
||
133 | xferID, packetID, data.Length); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | public bool RemoveXferUploader(UUID transactionID) |
||
138 | { |
||
139 | lock (XferUploaders) |
||
140 | { |
||
141 | bool removed = XferUploaders.Remove(transactionID); |
||
142 | |||
143 | if (!removed) |
||
144 | m_log.WarnFormat( |
||
145 | "[AGENT ASSET TRANSACTIONS]: Received request to remove xfer uploader with transaction ID {0} but none found", |
||
146 | transactionID); |
||
147 | // else |
||
148 | // m_log.DebugFormat( |
||
149 | // "[AGENT ASSET TRANSACTIONS]: Removed xfer uploader with transaction ID {0}", transactionID); |
||
150 | |||
151 | return removed; |
||
152 | } |
||
153 | } |
||
154 | |||
155 | public void RequestCreateInventoryItem(IClientAPI remoteClient, |
||
156 | UUID transactionID, UUID folderID, uint callbackID, |
||
157 | string description, string name, sbyte invType, |
||
158 | sbyte type, byte wearableType, uint nextOwnerMask) |
||
159 | { |
||
160 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
||
161 | |||
162 | uploader.RequestCreateInventoryItem( |
||
163 | remoteClient, folderID, callbackID, |
||
164 | description, name, invType, type, wearableType, nextOwnerMask); |
||
165 | } |
||
166 | |||
167 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
||
168 | SceneObjectPart part, UUID transactionID, |
||
169 | TaskInventoryItem item) |
||
170 | { |
||
171 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
||
172 | |||
173 | uploader.RequestUpdateTaskInventoryItem(remoteClient, item); |
||
174 | } |
||
175 | |||
176 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, |
||
177 | UUID transactionID, InventoryItemBase item) |
||
178 | { |
||
179 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
||
180 | |||
181 | uploader.RequestUpdateInventoryItem(remoteClient, item); |
||
182 | } |
||
183 | } |
||
184 | } |