diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 130 |
1 files changed, 44 insertions, 86 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 3d6e7f3..c66a4ea 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
41 | /// </summary> | 41 | /// </summary> |
42 | public class AgentAssetTransactions | 42 | public class AgentAssetTransactions |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | 46 | ||
46 | // Fields | 47 | // Fields |
47 | private bool m_dumpAssetsToFile; | 48 | private bool m_dumpAssetsToFile; |
48 | public AssetTransactionModule Manager; | 49 | private Scene m_Scene; |
49 | public UUID UserID; | 50 | public UUID UserID; |
50 | public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); | 51 | public Dictionary<UUID, AssetXferUploader> XferUploaders = |
52 | new Dictionary<UUID, AssetXferUploader>(); | ||
51 | 53 | ||
52 | // Methods | 54 | // Methods |
53 | public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) | 55 | public AgentAssetTransactions(UUID agentID, Scene scene, |
56 | bool dumpAssetsToFile) | ||
54 | { | 57 | { |
58 | m_Scene = scene; | ||
55 | UserID = agentID; | 59 | UserID = agentID; |
56 | Manager = manager; | ||
57 | m_dumpAssetsToFile = dumpAssetsToFile; | 60 | m_dumpAssetsToFile = dumpAssetsToFile; |
58 | } | 61 | } |
59 | 62 | ||
@@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
61 | { | 64 | { |
62 | if (!XferUploaders.ContainsKey(transactionID)) | 65 | if (!XferUploaders.ContainsKey(transactionID)) |
63 | { | 66 | { |
64 | AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); | 67 | AssetXferUploader uploader = new AssetXferUploader(m_Scene, |
68 | m_dumpAssetsToFile); | ||
65 | 69 | ||
66 | lock (XferUploaders) | 70 | lock (XferUploaders) |
67 | { | 71 | { |
@@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
88 | } | 92 | } |
89 | } | 93 | } |
90 | 94 | ||
91 | public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, | 95 | public void RequestCreateInventoryItem(IClientAPI remoteClient, |
92 | uint callbackID, string description, string name, sbyte invType, | 96 | UUID transactionID, UUID folderID, uint callbackID, |
93 | sbyte type, byte wearableType, uint nextOwnerMask) | 97 | string description, string name, sbyte invType, |
98 | sbyte type, byte wearableType, uint nextOwnerMask) | ||
94 | { | 99 | { |
95 | if (XferUploaders.ContainsKey(transactionID)) | 100 | if (XferUploaders.ContainsKey(transactionID)) |
96 | { | 101 | { |
97 | XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, | 102 | XferUploaders[transactionID].RequestCreateInventoryItem( |
98 | callbackID, description, name, invType, type, | 103 | remoteClient, transactionID, folderID, |
99 | wearableType, nextOwnerMask); | 104 | callbackID, description, name, invType, type, |
105 | wearableType, nextOwnerMask); | ||
100 | } | 106 | } |
101 | } | 107 | } |
102 | 108 | ||
103 | 109 | ||
104 | 110 | ||
105 | /// <summary> | 111 | /// <summary> |
106 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. | 112 | /// Get an uploaded asset. If the data is successfully retrieved, |
113 | /// the transaction will be removed. | ||
107 | /// </summary> | 114 | /// </summary> |
108 | /// <param name="transactionID"></param> | 115 | /// <param name="transactionID"></param> |
109 | /// <returns>The asset if the upload has completed, null if it has not.</returns> | 116 | /// <returns>The asset if the upload has completed, null if it has not.</returns> |
@@ -125,105 +132,56 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
125 | return null; | 132 | return null; |
126 | } | 133 | } |
127 | 134 | ||
128 | //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) | 135 | public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, |
129 | //{ | 136 | SceneObjectPart part, UUID transactionID, |
130 | // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); | 137 | TaskInventoryItem item) |
131 | // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | ||
132 | // ourClient.AgentId); | ||
133 | |||
134 | // if (userInfo != null) | ||
135 | // { | ||
136 | // InventoryItemBase item = new InventoryItemBase(); | ||
137 | // item.Owner = ourClient.AgentId; | ||
138 | // item.Creator = ourClient.AgentId; | ||
139 | // item.ID = UUID.Random(); | ||
140 | // item.AssetID = asset.FullID; | ||
141 | // item.Description = asset.Description; | ||
142 | // item.Name = asset.Name; | ||
143 | // item.AssetType = asset.Type; | ||
144 | // item.InvType = asset.Type; | ||
145 | // item.Folder = inventoryFolderID; | ||
146 | // item.BasePermissions = 0x7fffffff; | ||
147 | // item.CurrentPermissions = 0x7fffffff; | ||
148 | // item.EveryOnePermissions = 0; | ||
149 | // item.NextPermissions = nextPerms; | ||
150 | // item.Flags = wearableType; | ||
151 | // item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
152 | |||
153 | // userInfo.AddItem(item); | ||
154 | // ourClient.SendInventoryItemCreateUpdate(item); | ||
155 | // } | ||
156 | // else | ||
157 | // { | ||
158 | // m_log.ErrorFormat( | ||
159 | // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", | ||
160 | // ourClient.AgentId); | ||
161 | // } | ||
162 | //} | ||
163 | |||
164 | public void RequestUpdateTaskInventoryItem( | ||
165 | IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) | ||
166 | { | 138 | { |
167 | if (XferUploaders.ContainsKey(transactionID)) | 139 | if (XferUploaders.ContainsKey(transactionID)) |
168 | { | 140 | { |
169 | AssetBase asset = XferUploaders[transactionID].GetAssetData(); | 141 | AssetBase asset = GetTransactionAsset(transactionID); |
142 | |||
143 | // Only legacy viewers use this, and they prefer CAPS, which | ||
144 | // we have, so this really never runs. | ||
145 | // Allow it, but only for "safe" types. | ||
146 | if ((InventoryType)item.InvType != InventoryType.Notecard && | ||
147 | (InventoryType)item.InvType != InventoryType.LSL) | ||
148 | return; | ||
149 | |||
170 | if (asset != null) | 150 | if (asset != null) |
171 | { | 151 | { |
172 | m_log.DebugFormat( | 152 | asset.FullID = UUID.Random(); |
173 | "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", | ||
174 | item.Name, part.Name, transactionID); | ||
175 | |||
176 | asset.Name = item.Name; | 153 | asset.Name = item.Name; |
177 | asset.Description = item.Description; | 154 | asset.Description = item.Description; |
178 | asset.Type = (sbyte)item.Type; | 155 | asset.Type = (sbyte)item.Type; |
179 | item.AssetID = asset.FullID; | 156 | item.AssetID = asset.FullID; |
180 | 157 | ||
181 | Manager.MyScene.AssetService.Store(asset); | 158 | m_Scene.AssetService.Store(asset); |
182 | 159 | ||
183 | if (part.Inventory.UpdateInventoryItem(item)) | 160 | part.Inventory.UpdateInventoryItem(item); |
184 | { | ||
185 | if ((InventoryType)item.InvType == InventoryType.Notecard) | ||
186 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
187 | else if ((InventoryType)item.InvType == InventoryType.LSL) | ||
188 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
189 | else | ||
190 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
191 | |||
192 | part.GetProperties(remoteClient); | ||
193 | } | ||
194 | } | 161 | } |
195 | } | 162 | } |
196 | } | 163 | } |
197 | 164 | ||
198 | 165 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, | |
199 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, | 166 | UUID transactionID, InventoryItemBase item) |
200 | InventoryItemBase item) | ||
201 | { | 167 | { |
202 | if (XferUploaders.ContainsKey(transactionID)) | 168 | if (XferUploaders.ContainsKey(transactionID)) |
203 | { | 169 | { |
204 | UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); | 170 | AssetBase asset = GetTransactionAsset(transactionID); |
205 | 171 | ||
206 | AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); | 172 | if (asset != null) |
207 | |||
208 | if (asset == null) | ||
209 | { | ||
210 | asset = GetTransactionAsset(transactionID); | ||
211 | } | ||
212 | |||
213 | if (asset != null && asset.FullID == assetID) | ||
214 | { | 173 | { |
215 | // Assets never get updated, new ones get created | ||
216 | asset.FullID = UUID.Random(); | 174 | asset.FullID = UUID.Random(); |
217 | asset.Name = item.Name; | 175 | asset.Name = item.Name; |
218 | asset.Description = item.Description; | 176 | asset.Description = item.Description; |
219 | asset.Type = (sbyte)item.AssetType; | 177 | asset.Type = (sbyte)item.AssetType; |
220 | item.AssetID = asset.FullID; | 178 | item.AssetID = asset.FullID; |
221 | 179 | ||
222 | Manager.MyScene.AssetService.Store(asset); | 180 | m_Scene.AssetService.Store(asset); |
223 | } | ||
224 | 181 | ||
225 | IInventoryService invService = Manager.MyScene.InventoryService; | 182 | IInventoryService invService = m_Scene.InventoryService; |
226 | invService.UpdateItem(item); | 183 | invService.UpdateItem(item); |
184 | } | ||
227 | } | 185 | } |
228 | } | 186 | } |
229 | } | 187 | } |