diff options
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 120 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs | 367 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | 5 |
4 files changed, 23 insertions, 485 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 9869a99..e9e2dca 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
55 | public IJ2KDecoder J2KDecoder; | 55 | public IJ2KDecoder J2KDecoder; |
56 | public IAssetService AssetService; | 56 | public IAssetService AssetService; |
57 | public UUID AgentID; | 57 | public UUID AgentID; |
58 | public IHyperAssetService HyperAssets; | 58 | public IInventoryAccessModule InventoryAccessModule; |
59 | public OpenJPEG.J2KLayerInfo[] Layers; | 59 | public OpenJPEG.J2KLayerInfo[] Layers; |
60 | public bool IsDecoded; | 60 | public bool IsDecoded; |
61 | public bool HasAsset; | 61 | public bool HasAsset; |
@@ -375,14 +375,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
375 | UUID assetID = UUID.Zero; | 375 | UUID assetID = UUID.Zero; |
376 | if (asset != null) | 376 | if (asset != null) |
377 | assetID = asset.FullID; | 377 | assetID = asset.FullID; |
378 | else if ((HyperAssets != null) && (sender != HyperAssets)) | 378 | else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule)) |
379 | { | 379 | { |
380 | // Try the user's inventory, but only if it's different from the regions' | 380 | // Unfortunately we need this here, there's no other way. |
381 | string userAssets = HyperAssets.GetUserAssetServer(AgentID); | 381 | // This is due to the fact that textures opened directly from the agent's inventory |
382 | if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer())) | 382 | // don't have any distinguishing feature. As such, in order to serve those when the |
383 | // foreign user is visiting, we need to try again after the first fail to the local | ||
384 | // asset service. | ||
385 | string assetServerURL = string.Empty; | ||
386 | if (InventoryAccessModule.IsForeignUser(AgentID, out assetServerURL)) | ||
383 | { | 387 | { |
384 | m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id); | 388 | m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id); |
385 | AssetService.Get(userAssets + "/" + id, HyperAssets, AssetReceived); | 389 | AssetService.Get(assetServerURL + "/" + id, InventoryAccessModule, AssetReceived); |
386 | return; | 390 | return; |
387 | } | 391 | } |
388 | } | 392 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index d2824bd..0aec01a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -357,7 +357,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
357 | protected uint m_agentFOVCounter; | 357 | protected uint m_agentFOVCounter; |
358 | 358 | ||
359 | protected IAssetService m_assetService; | 359 | protected IAssetService m_assetService; |
360 | private IHyperAssetService m_hyperAssets; | ||
361 | private const bool m_checkPackets = true; | 360 | private const bool m_checkPackets = true; |
362 | 361 | ||
363 | private Timer m_propertiesPacketTimer; | 362 | private Timer m_propertiesPacketTimer; |
@@ -432,7 +431,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
432 | // m_attachmentsSent = new HashSet<uint>(); | 431 | // m_attachmentsSent = new HashSet<uint>(); |
433 | 432 | ||
434 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | 433 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); |
435 | m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); | ||
436 | m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); | 434 | m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); |
437 | m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); | 435 | m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); |
438 | m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); | 436 | m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion()); |
@@ -3680,30 +3678,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3680 | 3678 | ||
3681 | #endregion Primitive Packet/Data Sending Methods | 3679 | #endregion Primitive Packet/Data Sending Methods |
3682 | 3680 | ||
3683 | /// <summary> | ||
3684 | /// | ||
3685 | /// </summary> | ||
3686 | /// <param name="localID"></param> | ||
3687 | /// <param name="rotation"></param> | ||
3688 | /// <param name="attachPoint"></param> | ||
3689 | public void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID) | ||
3690 | { | ||
3691 | if (attachPoint > 30 && ownerID != AgentId) // Someone else's HUD | ||
3692 | return; | ||
3693 | |||
3694 | ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach); | ||
3695 | // TODO: don't create new blocks if recycling an old packet | ||
3696 | attach.AgentData.AgentID = AgentId; | ||
3697 | attach.AgentData.SessionID = m_sessionId; | ||
3698 | attach.AgentData.AttachmentPoint = attachPoint; | ||
3699 | attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; | ||
3700 | attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); | ||
3701 | attach.ObjectData[0].ObjectLocalID = localID; | ||
3702 | attach.ObjectData[0].Rotation = rotation; | ||
3703 | attach.Header.Zerocoded = true; | ||
3704 | OutPacket(attach, ThrottleOutPacketType.Task); | ||
3705 | } | ||
3706 | |||
3707 | void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) | 3681 | void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) |
3708 | { | 3682 | { |
3709 | if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) | 3683 | if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) |
@@ -5733,7 +5707,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5733 | { | 5707 | { |
5734 | if (att.ObjectData.Length > 0) | 5708 | if (att.ObjectData.Length > 0) |
5735 | { | 5709 | { |
5736 | handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false); | 5710 | handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false); |
5737 | } | 5711 | } |
5738 | } | 5712 | } |
5739 | } | 5713 | } |
@@ -7196,59 +7170,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7196 | } | 7170 | } |
7197 | else // Agent | 7171 | else // Agent |
7198 | { | 7172 | { |
7199 | IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>(); | 7173 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); |
7200 | InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId); | 7174 | if (invAccess != null) |
7201 | assetRequestItem = invService.GetItem(assetRequestItem); | ||
7202 | if (assetRequestItem == null) | ||
7203 | { | 7175 | { |
7204 | ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>(); | 7176 | if (!invAccess.GetAgentInventoryItem(this, itemID, requestID)) |
7205 | if (lib != null) | 7177 | return false; |
7206 | assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); | ||
7207 | if (assetRequestItem == null) | ||
7208 | return true; | ||
7209 | } | ||
7210 | 7178 | ||
7211 | // At this point, we need to apply perms | ||
7212 | // only to notecards and scripts. All | ||
7213 | // other asset types are always available | ||
7214 | // | ||
7215 | if (assetRequestItem.AssetType == (int)AssetType.LSLText) | ||
7216 | { | ||
7217 | if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId)) | ||
7218 | { | ||
7219 | SendAgentAlertMessage("Insufficient permissions to view script", false); | ||
7220 | return true; | ||
7221 | } | ||
7222 | } | ||
7223 | else if (assetRequestItem.AssetType == (int)AssetType.Notecard) | ||
7224 | { | ||
7225 | if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId)) | ||
7226 | { | ||
7227 | SendAgentAlertMessage("Insufficient permissions to view notecard", false); | ||
7228 | return true; | ||
7229 | } | ||
7230 | } | 7179 | } |
7180 | else | ||
7181 | return false; | ||
7231 | 7182 | ||
7232 | if (assetRequestItem.AssetID != requestID) | ||
7233 | { | ||
7234 | m_log.WarnFormat( | ||
7235 | "[CLIENT]: {0} requested asset {1} from item {2} but this does not match item's asset {3}", | ||
7236 | Name, requestID, itemID, assetRequestItem.AssetID); | ||
7237 | return true; | ||
7238 | } | ||
7239 | } | 7183 | } |
7240 | } | 7184 | } |
7241 | } | 7185 | } |
7242 | 7186 | ||
7243 | //m_assetCache.AddAssetRequest(this, transfer); | ||
7244 | |||
7245 | MakeAssetRequest(transfer, taskID); | 7187 | MakeAssetRequest(transfer, taskID); |
7246 | 7188 | ||
7247 | /* RequestAsset = OnRequestAsset; | ||
7248 | if (RequestAsset != null) | ||
7249 | { | ||
7250 | RequestAsset(this, transfer); | ||
7251 | }*/ | ||
7252 | return true; | 7189 | return true; |
7253 | } | 7190 | } |
7254 | 7191 | ||
@@ -11459,15 +11396,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11459 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) | 11396 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) |
11460 | { | 11397 | { |
11461 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); | 11398 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); |
11462 | //m_log.Debug("[XXX] inventory asset request " + requestID); | ||
11463 | //if (taskID == UUID.Zero) // Agent | ||
11464 | // if (m_scene is HGScene) | ||
11465 | // { | ||
11466 | // m_log.Debug("[XXX] hg asset request " + requestID); | ||
11467 | // // We may need to fetch the asset from the user's asset server into the local asset server | ||
11468 | // HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper; | ||
11469 | // mapper.Get(requestID, AgentId); | ||
11470 | // } | ||
11471 | } | 11399 | } |
11472 | 11400 | ||
11473 | // m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); | 11401 | // m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); |
@@ -11483,49 +11411,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11483 | /// <param name="asset"></param> | 11411 | /// <param name="asset"></param> |
11484 | protected void AssetReceived(string id, Object sender, AssetBase asset) | 11412 | protected void AssetReceived(string id, Object sender, AssetBase asset) |
11485 | { | 11413 | { |
11414 | if (asset == null) | ||
11415 | return; | ||
11416 | |||
11486 | TransferRequestPacket transferRequest = (TransferRequestPacket)sender; | 11417 | TransferRequestPacket transferRequest = (TransferRequestPacket)sender; |
11487 | 11418 | ||
11488 | UUID requestID = UUID.Zero; | 11419 | UUID requestID = UUID.Zero; |
11489 | byte source = (byte)SourceType.Asset; | 11420 | byte source = (byte)SourceType.Asset; |
11490 | 11421 | ||
11491 | if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) | 11422 | if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) |
11492 | || (transferRequest.TransferInfo.SourceType == 2222)) | ||
11493 | { | 11423 | { |
11494 | requestID = new UUID(transferRequest.TransferInfo.Params, 0); | 11424 | requestID = new UUID(transferRequest.TransferInfo.Params, 0); |
11495 | } | 11425 | } |
11496 | else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) | 11426 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) |
11497 | || (transferRequest.TransferInfo.SourceType == 3333)) | ||
11498 | { | 11427 | { |
11499 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); | 11428 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); |
11500 | source = (byte)SourceType.SimInventoryItem; | 11429 | source = (byte)SourceType.SimInventoryItem; |
11501 | //m_log.Debug("asset request " + requestID); | 11430 | //m_log.Debug("asset request " + requestID); |
11502 | } | 11431 | } |
11503 | 11432 | ||
11504 | if (null == asset) | ||
11505 | { | ||
11506 | if ((m_hyperAssets != null) && (transferRequest.TransferInfo.SourceType < 2000)) | ||
11507 | { | ||
11508 | // Try the user's inventory, but only if it's different from the regions' | ||
11509 | string userAssets = m_hyperAssets.GetUserAssetServer(AgentId); | ||
11510 | if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) | ||
11511 | { | ||
11512 | m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); | ||
11513 | if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) | ||
11514 | transferRequest.TransferInfo.SourceType = 2222; // marker | ||
11515 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) | ||
11516 | transferRequest.TransferInfo.SourceType = 3333; // marker | ||
11517 | |||
11518 | m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); | ||
11519 | return; | ||
11520 | } | ||
11521 | } | ||
11522 | |||
11523 | //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); | ||
11524 | |||
11525 | // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. | ||
11526 | return; | ||
11527 | } | ||
11528 | |||
11529 | // Scripts cannot be retrieved by direct request | 11433 | // Scripts cannot be retrieved by direct request |
11530 | if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10) | 11434 | if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10) |
11531 | return; | 11435 | return; |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs deleted file mode 100644 index 10e5a95..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs +++ /dev/null | |||
@@ -1,367 +0,0 @@ | |||
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; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// A work in progress, to contain the SL specific file transfer code that is currently in various region modules | ||
37 | /// This file currently contains multiple classes that need to be split out into their own files. | ||
38 | /// </summary> | ||
39 | public class LLFileTransfer : IClientFileTransfer | ||
40 | { | ||
41 | protected IClientAPI m_clientAPI; | ||
42 | |||
43 | /// Dictionary of handlers for uploading files from client | ||
44 | /// TODO: Need to add cleanup code to remove handlers that have completed their upload | ||
45 | protected Dictionary<ulong, XferUploadHandler> m_uploadHandlers; | ||
46 | protected object m_uploadHandlersLock = new object(); | ||
47 | |||
48 | |||
49 | /// <summary> | ||
50 | /// Dictionary of files ready to be sent to clients | ||
51 | /// </summary> | ||
52 | protected static Dictionary<string, byte[]> m_files; | ||
53 | |||
54 | /// <summary> | ||
55 | /// Dictionary of Download Transfers in progess | ||
56 | /// </summary> | ||
57 | protected Dictionary<ulong, XferDownloadHandler> m_downloadHandlers = new Dictionary<ulong, XferDownloadHandler>(); | ||
58 | |||
59 | |||
60 | public LLFileTransfer(IClientAPI clientAPI) | ||
61 | { | ||
62 | m_uploadHandlers = new Dictionary<ulong, XferUploadHandler>(); | ||
63 | m_clientAPI = clientAPI; | ||
64 | |||
65 | m_clientAPI.OnXferReceive += XferReceive; | ||
66 | m_clientAPI.OnAbortXfer += AbortXferUploadHandler; | ||
67 | } | ||
68 | |||
69 | public void Close() | ||
70 | { | ||
71 | if (m_clientAPI != null) | ||
72 | { | ||
73 | m_clientAPI.OnXferReceive -= XferReceive; | ||
74 | m_clientAPI.OnAbortXfer -= AbortXferUploadHandler; | ||
75 | m_clientAPI = null; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | #region Upload Handling | ||
80 | |||
81 | public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) | ||
82 | { | ||
83 | if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null)) | ||
84 | { | ||
85 | return false; | ||
86 | } | ||
87 | |||
88 | XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName); | ||
89 | |||
90 | return StartUpload(uploader, uploadCompleteCallback, abortCallback); | ||
91 | } | ||
92 | |||
93 | public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) | ||
94 | { | ||
95 | if ((fileID == UUID.Zero) || (uploadCompleteCallback == null)) | ||
96 | { | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID); | ||
101 | |||
102 | return StartUpload(uploader, uploadCompleteCallback, abortCallback); | ||
103 | } | ||
104 | |||
105 | private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback) | ||
106 | { | ||
107 | uploader.UploadDone += uploadCompleteCallback; | ||
108 | uploader.UploadDone += RemoveXferUploadHandler; | ||
109 | |||
110 | if (abortCallback != null) | ||
111 | { | ||
112 | uploader.UploadAborted += abortCallback; | ||
113 | } | ||
114 | |||
115 | lock (m_uploadHandlersLock) | ||
116 | { | ||
117 | if (!m_uploadHandlers.ContainsKey(uploader.XferID)) | ||
118 | { | ||
119 | m_uploadHandlers.Add(uploader.XferID, uploader); | ||
120 | uploader.RequestStartXfer(m_clientAPI); | ||
121 | return true; | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | // something went wrong with the xferID allocation | ||
126 | uploader.UploadDone -= uploadCompleteCallback; | ||
127 | uploader.UploadDone -= RemoveXferUploadHandler; | ||
128 | if (abortCallback != null) | ||
129 | { | ||
130 | uploader.UploadAborted -= abortCallback; | ||
131 | } | ||
132 | return false; | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | protected void AbortXferUploadHandler(IClientAPI remoteClient, ulong xferID) | ||
138 | { | ||
139 | lock (m_uploadHandlersLock) | ||
140 | { | ||
141 | if (m_uploadHandlers.ContainsKey(xferID)) | ||
142 | { | ||
143 | m_uploadHandlers[xferID].AbortUpload(remoteClient); | ||
144 | m_uploadHandlers.Remove(xferID); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | |||
149 | protected void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | ||
150 | { | ||
151 | lock (m_uploadHandlersLock) | ||
152 | { | ||
153 | if (m_uploadHandlers.ContainsKey(xferID)) | ||
154 | { | ||
155 | m_uploadHandlers[xferID].XferReceive(remoteClient, xferID, packetID, data); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | protected void RemoveXferUploadHandler(string filename, UUID fileID, ulong transferID, byte[] fileData, IClientAPI remoteClient) | ||
161 | { | ||
162 | |||
163 | } | ||
164 | #endregion | ||
165 | |||
166 | } | ||
167 | |||
168 | public class XferUploadHandler | ||
169 | { | ||
170 | private AssetBase m_asset; | ||
171 | |||
172 | public event UploadComplete UploadDone; | ||
173 | public event UploadAborted UploadAborted; | ||
174 | |||
175 | private sbyte type = 0; | ||
176 | |||
177 | public ulong mXferID; | ||
178 | private UploadComplete handlerUploadDone; | ||
179 | private UploadAborted handlerAbort; | ||
180 | |||
181 | private bool m_complete = false; | ||
182 | |||
183 | public bool UploadComplete | ||
184 | { | ||
185 | get { return m_complete; } | ||
186 | } | ||
187 | |||
188 | public XferUploadHandler(IClientAPI pRemoteClient, string pClientFilename) | ||
189 | { | ||
190 | Initialise(UUID.Zero, pClientFilename); | ||
191 | } | ||
192 | |||
193 | public XferUploadHandler(IClientAPI pRemoteClient, UUID fileID) | ||
194 | { | ||
195 | Initialise(fileID, String.Empty); | ||
196 | } | ||
197 | |||
198 | private void Initialise(UUID fileID, string fileName) | ||
199 | { | ||
200 | m_asset = new AssetBase(fileID, fileName, type, UUID.Zero.ToString()); | ||
201 | m_asset.Data = new byte[0]; | ||
202 | m_asset.Description = "empty"; | ||
203 | m_asset.Local = true; | ||
204 | m_asset.Temporary = true; | ||
205 | mXferID = Util.GetNextXferID(); | ||
206 | } | ||
207 | |||
208 | public ulong XferID | ||
209 | { | ||
210 | get { return mXferID; } | ||
211 | } | ||
212 | |||
213 | public void RequestStartXfer(IClientAPI pRemoteClient) | ||
214 | { | ||
215 | m_asset.Metadata.CreatorID = pRemoteClient.AgentId.ToString(); | ||
216 | |||
217 | if (!String.IsNullOrEmpty(m_asset.Name)) | ||
218 | { | ||
219 | pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name)); | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /// <summary> | ||
228 | /// Process transfer data received from the client. | ||
229 | /// </summary> | ||
230 | /// <param name="xferID"></param> | ||
231 | /// <param name="packetID"></param> | ||
232 | /// <param name="data"></param> | ||
233 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | ||
234 | { | ||
235 | if (mXferID == xferID) | ||
236 | { | ||
237 | if (m_asset.Data.Length > 1) | ||
238 | { | ||
239 | byte[] destinationArray = new byte[m_asset.Data.Length + data.Length]; | ||
240 | Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length); | ||
241 | Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length); | ||
242 | m_asset.Data = destinationArray; | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | byte[] buffer2 = new byte[data.Length - 4]; | ||
247 | Array.Copy(data, 4, buffer2, 0, data.Length - 4); | ||
248 | m_asset.Data = buffer2; | ||
249 | } | ||
250 | |||
251 | remoteClient.SendConfirmXfer(xferID, packetID); | ||
252 | |||
253 | if ((packetID & 0x80000000) != 0) | ||
254 | { | ||
255 | SendCompleteMessage(remoteClient); | ||
256 | |||
257 | } | ||
258 | } | ||
259 | } | ||
260 | |||
261 | protected void SendCompleteMessage(IClientAPI remoteClient) | ||
262 | { | ||
263 | m_complete = true; | ||
264 | handlerUploadDone = UploadDone; | ||
265 | if (handlerUploadDone != null) | ||
266 | { | ||
267 | handlerUploadDone(m_asset.Name, m_asset.FullID, mXferID, m_asset.Data, remoteClient); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | public void AbortUpload(IClientAPI remoteClient) | ||
272 | { | ||
273 | handlerAbort = UploadAborted; | ||
274 | if (handlerAbort != null) | ||
275 | { | ||
276 | handlerAbort(m_asset.Name, m_asset.FullID, mXferID, remoteClient); | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | public class XferDownloadHandler | ||
282 | { | ||
283 | public IClientAPI Client; | ||
284 | private bool complete; | ||
285 | public byte[] Data = new byte[0]; | ||
286 | public int DataPointer = 0; | ||
287 | public string FileName = String.Empty; | ||
288 | public uint Packet = 0; | ||
289 | public uint Serial = 1; | ||
290 | public ulong XferID = 0; | ||
291 | |||
292 | public XferDownloadHandler(string fileName, byte[] data, ulong xferID, IClientAPI client) | ||
293 | { | ||
294 | FileName = fileName; | ||
295 | Data = data; | ||
296 | XferID = xferID; | ||
297 | Client = client; | ||
298 | } | ||
299 | |||
300 | public XferDownloadHandler() | ||
301 | { | ||
302 | } | ||
303 | |||
304 | /// <summary> | ||
305 | /// Start a transfer | ||
306 | /// </summary> | ||
307 | /// <returns>True if the transfer is complete, false if not</returns> | ||
308 | public bool StartSend() | ||
309 | { | ||
310 | if (Data.Length < 1000) | ||
311 | { | ||
312 | // for now (testing) we only support files under 1000 bytes | ||
313 | byte[] transferData = new byte[Data.Length + 4]; | ||
314 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | ||
315 | Array.Copy(Data, 0, transferData, 4, Data.Length); | ||
316 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | ||
317 | |||
318 | complete = true; | ||
319 | } | ||
320 | else | ||
321 | { | ||
322 | byte[] transferData = new byte[1000 + 4]; | ||
323 | Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); | ||
324 | Array.Copy(Data, 0, transferData, 4, 1000); | ||
325 | Client.SendXferPacket(XferID, 0, transferData); | ||
326 | Packet++; | ||
327 | DataPointer = 1000; | ||
328 | } | ||
329 | |||
330 | return complete; | ||
331 | } | ||
332 | |||
333 | /// <summary> | ||
334 | /// Respond to an ack packet from the client | ||
335 | /// </summary> | ||
336 | /// <param name="packet"></param> | ||
337 | /// <returns>True if the transfer is complete, false otherwise</returns> | ||
338 | public bool AckPacket(uint packet) | ||
339 | { | ||
340 | if (!complete) | ||
341 | { | ||
342 | if ((Data.Length - DataPointer) > 1000) | ||
343 | { | ||
344 | byte[] transferData = new byte[1000]; | ||
345 | Array.Copy(Data, DataPointer, transferData, 0, 1000); | ||
346 | Client.SendXferPacket(XferID, Packet, transferData); | ||
347 | Packet++; | ||
348 | DataPointer += 1000; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | byte[] transferData = new byte[Data.Length - DataPointer]; | ||
353 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); | ||
354 | uint endPacket = Packet |= (uint)0x80000000; | ||
355 | Client.SendXferPacket(XferID, endPacket, transferData); | ||
356 | Packet++; | ||
357 | DataPointer += (Data.Length - DataPointer); | ||
358 | |||
359 | complete = true; | ||
360 | } | ||
361 | } | ||
362 | |||
363 | return complete; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 938cf50..9e0db12 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | |||
@@ -58,8 +58,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
58 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); | 58 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); |
59 | private object m_syncRoot = new object(); | 59 | private object m_syncRoot = new object(); |
60 | 60 | ||
61 | private IHyperAssetService m_hyperAssets; | ||
62 | |||
63 | public LLClientView Client { get { return m_client; } } | 61 | public LLClientView Client { get { return m_client; } } |
64 | public AssetBase MissingImage { get { return m_missingImage; } } | 62 | public AssetBase MissingImage { get { return m_missingImage; } } |
65 | 63 | ||
@@ -75,7 +73,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
75 | m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); | 73 | m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); |
76 | 74 | ||
77 | m_j2kDecodeModule = pJ2kDecodeModule; | 75 | m_j2kDecodeModule = pJ2kDecodeModule; |
78 | m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>(); | ||
79 | } | 76 | } |
80 | 77 | ||
81 | /// <summary> | 78 | /// <summary> |
@@ -149,7 +146,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
149 | imgrequest.J2KDecoder = m_j2kDecodeModule; | 146 | imgrequest.J2KDecoder = m_j2kDecodeModule; |
150 | imgrequest.AssetService = m_assetCache; | 147 | imgrequest.AssetService = m_assetCache; |
151 | imgrequest.AgentID = m_client.AgentId; | 148 | imgrequest.AgentID = m_client.AgentId; |
152 | imgrequest.HyperAssets = m_hyperAssets; | 149 | imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>(); |
153 | imgrequest.DiscardLevel = newRequest.DiscardLevel; | 150 | imgrequest.DiscardLevel = newRequest.DiscardLevel; |
154 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); | 151 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); |
155 | imgrequest.Priority = newRequest.Priority; | 152 | imgrequest.Priority = newRequest.Priority; |