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