aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
diff options
context:
space:
mode:
authorMelanie2010-12-04 04:33:14 +0100
committerMelanie2010-12-04 04:24:55 +0000
commitea17b262a35df16ebdd79891520907b05d3b78a6 (patch)
treeffbf06ea2de75d8b2c2b7db698a39feccfef1c14 /OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
parentVarious bug fixes for appearance handling: more aggressive reset of textures ... (diff)
downloadopensim-SC_OLD-ea17b262a35df16ebdd79891520907b05d3b78a6.zip
opensim-SC_OLD-ea17b262a35df16ebdd79891520907b05d3b78a6.tar.gz
opensim-SC_OLD-ea17b262a35df16ebdd79891520907b05d3b78a6.tar.bz2
opensim-SC_OLD-ea17b262a35df16ebdd79891520907b05d3b78a6.tar.xz
Convert the agent asset transactions module to a new style module.
Refactor to remove the property "MyScene" and the pointless circular refs to the managing classes. Converted the module to a non-shared module. Reformatted source for 80 columns. Removed the special role the module had in the old loader.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs43
1 files changed, 25 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index 4609738..a7929ba 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -31,7 +31,7 @@ using System.Reflection;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
@@ -50,17 +50,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
50 private bool m_finished = false; 50 private bool m_finished = false;
51 private string m_name = String.Empty; 51 private string m_name = String.Empty;
52 private bool m_storeLocal; 52 private bool m_storeLocal;
53 private AgentAssetTransactions m_userTransactions;
54 private uint nextPerm = 0; 53 private uint nextPerm = 0;
55 private IClientAPI ourClient; 54 private IClientAPI ourClient;
56 private UUID TransactionID = UUID.Zero; 55 private UUID TransactionID = UUID.Zero;
57 private sbyte type = 0; 56 private sbyte type = 0;
58 private byte wearableType = 0; 57 private byte wearableType = 0;
59 public ulong XferID; 58 public ulong XferID;
59 private Scene m_Scene;
60 60
61 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 61 public AssetXferUploader(Scene scene, bool dumpAssetToFile)
62 { 62 {
63 m_userTransactions = transactions; 63 m_Scene = scene;
64 m_dumpAssetToFile = dumpAssetToFile; 64 m_dumpAssetToFile = dumpAssetToFile;
65 } 65 }
66 66
@@ -108,11 +108,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
108 /// <param name="packetID"></param> 108 /// <param name="packetID"></param>
109 /// <param name="data"></param> 109 /// <param name="data"></param>
110 /// <returns>True if the transfer is complete, false otherwise</returns> 110 /// <returns>True if the transfer is complete, false otherwise</returns>
111 public bool Initialise(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, 111 public bool Initialise(IClientAPI remoteClient, UUID assetID,
112 bool storeLocal, bool tempFile) 112 UUID transaction, sbyte type, byte[] data, bool storeLocal,
113 bool tempFile)
113 { 114 {
114 ourClient = remoteClient; 115 ourClient = remoteClient;
115 m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); 116 m_asset = new AssetBase(assetID, "blank", type,
117 remoteClient.AgentId.ToString());
116 m_asset.Data = data; 118 m_asset.Data = data;
117 m_asset.Description = "empty"; 119 m_asset.Description = "empty";
118 m_asset.Local = storeLocal; 120 m_asset.Local = storeLocal;
@@ -137,12 +139,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
137 protected void RequestStartXfer() 139 protected void RequestStartXfer()
138 { 140 {
139 XferID = Util.GetNextXferID(); 141 XferID = Util.GetNextXferID();
140 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); 142 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID,
143 0, new byte[0]);
141 } 144 }
142 145
143 protected void SendCompleteMessage() 146 protected void SendCompleteMessage()
144 { 147 {
145 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); 148 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true,
149 m_asset.FullID);
146 150
147 m_finished = true; 151 m_finished = true;
148 if (m_createItem) 152 if (m_createItem)
@@ -151,18 +155,20 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
151 } 155 }
152 else if (m_storeLocal) 156 else if (m_storeLocal)
153 { 157 {
154 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 158 m_Scene.AssetService.Store(m_asset);
155 } 159 }
156 160
157 m_log.DebugFormat( 161 m_log.DebugFormat(
158 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); 162 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}",
163 m_asset.FullID, TransactionID);
159 164
160 if (m_dumpAssetToFile) 165 if (m_dumpAssetToFile)
161 { 166 {
162 DateTime now = DateTime.Now; 167 DateTime now = DateTime.Now;
163 string filename = 168 string filename =
164 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, 169 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
165 now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); 170 now.Year, now.Month, now.Day, now.Hour, now.Minute,
171 now.Second, m_asset.Name, m_asset.Type);
166 SaveAssetToFile(filename, m_asset.Data); 172 SaveAssetToFile(filename, m_asset.Data);
167 } 173 }
168 } 174 }
@@ -181,9 +187,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
181 fs.Close(); 187 fs.Close();
182 } 188 }
183 189
184 public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, 190 public void RequestCreateInventoryItem(IClientAPI remoteClient,
185 uint callbackID, string description, string name, sbyte invType, 191 UUID transactionID, UUID folderID, uint callbackID,
186 sbyte type, byte wearableType, uint nextOwnerMask) 192 string description, string name, sbyte invType,
193 sbyte type, byte wearableType, uint nextOwnerMask)
187 { 194 {
188 if (TransactionID == transactionID) 195 if (TransactionID == transactionID)
189 { 196 {
@@ -212,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
212 219
213 private void DoCreateItem(uint callbackID) 220 private void DoCreateItem(uint callbackID)
214 { 221 {
215 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 222 m_Scene.AssetService.Store(m_asset);
216 223
217 InventoryItemBase item = new InventoryItemBase(); 224 InventoryItemBase item = new InventoryItemBase();
218 item.Owner = ourClient.AgentId; 225 item.Owner = ourClient.AgentId;
@@ -232,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
232 item.Flags = (uint) wearableType; 239 item.Flags = (uint) wearableType;
233 item.CreationDate = Util.UnixTimeSinceEpoch(); 240 item.CreationDate = Util.UnixTimeSinceEpoch();
234 241
235 if (m_userTransactions.Manager.MyScene.AddInventoryItem(item)) 242 if (m_Scene.AddInventoryItem(item))
236 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 243 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
237 else 244 else
238 ourClient.SendAlertMessage("Unable to create inventory item"); 245 ourClient.SendAlertMessage("Unable to create inventory item");