aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs132
1 files changed, 111 insertions, 21 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 2a91624..689b4d5 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes; 32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Framework.Communications.Cache;
33 34
34namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction 35namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
35{ 36{
@@ -38,17 +39,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
38 /// </summary> 39 /// </summary>
39 public class AgentAssetTransactions 40 public class AgentAssetTransactions
40 { 41 {
41 //private static readonly log4net.ILog m_log 42 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 // Fields 44 // Fields
45 private bool m_dumpAssetsToFile; 45 private bool m_dumpAssetsToFile;
46 public AgentAssetTransactionsManager Manager; 46 public AssetTransactionModule Manager;
47 public UUID UserID; 47 public UUID UserID;
48 public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); 48 public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>();
49 49
50 // Methods 50 // Methods
51 public AgentAssetTransactions(UUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) 51 public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile)
52 { 52 {
53 UserID = agentID; 53 UserID = agentID;
54 Manager = manager; 54 Manager = manager;
@@ -97,24 +97,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
97 wearableType, nextOwnerMask); 97 wearableType, nextOwnerMask);
98 } 98 }
99 } 99 }
100
101 public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID,
102 InventoryItemBase item)
103 {
104 if (XferUploaders.ContainsKey(transactionID))
105 {
106 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item);
107 }
108 }
109 100
110 public void RequestUpdateTaskInventoryItem( 101
111 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
112 {
113 if (XferUploaders.ContainsKey(transactionID))
114 {
115 XferUploaders[transactionID].RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
116 }
117 }
118 102
119 /// <summary> 103 /// <summary>
120 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 104 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
@@ -138,5 +122,111 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
138 122
139 return null; 123 return null;
140 } 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.Name = item.Name;
175 asset.Description = item.Description;
176 asset.Type = (sbyte)item.Type;
177 item.AssetID = asset.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.FullID == assetID)
210 {
211 // Assets never get updated, new ones get created
212 asset.FullID = UUID.Random();
213 asset.Name = item.Name;
214 asset.Description = item.Description;
215 asset.Type = (sbyte)item.AssetType;
216 item.AssetID = asset.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 }
141 } 231 }
142} 232}