aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/IClientFileTransfer.cs3
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs44
2 files changed, 44 insertions, 3 deletions
diff --git a/OpenSim/Framework/IClientFileTransfer.cs b/OpenSim/Framework/IClientFileTransfer.cs
index 8cdf795..ec8e623 100644
--- a/OpenSim/Framework/IClientFileTransfer.cs
+++ b/OpenSim/Framework/IClientFileTransfer.cs
@@ -1,10 +1,11 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenMetaverse;
4 5
5namespace OpenSim.Framework 6namespace OpenSim.Framework
6{ 7{
7 public delegate void UploadComplete(string filename, byte[] fileData, IClientAPI remoteClient); 8 public delegate void UploadComplete(string filename, UUID fileID, byte[] fileData, IClientAPI remoteClient);
8 public delegate void UploadAborted(string filename, ulong id, IClientAPI remoteClient); 9 public delegate void UploadAborted(string filename, ulong id, IClientAPI remoteClient);
9 10
10 public interface IClientFileTransfer 11 public interface IClientFileTransfer
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
index b2e7bc4..5526a16 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs
@@ -17,6 +17,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
17 { 17 {
18 protected IClientAPI m_clientAPI; 18 protected IClientAPI m_clientAPI;
19 19
20 /// Dictionary of handlers for uploading files from client
21 /// TODO: Need to add cleanup code to remove handlers that have completed their upload
20 protected Dictionary<ulong, XferHandler> m_handlers; 22 protected Dictionary<ulong, XferHandler> m_handlers;
21 protected object m_handlerLock = new object(); 23 protected object m_handlerLock = new object();
22 24
@@ -47,6 +49,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
47 } 49 }
48 50
49 XferHandler uploader = new XferHandler(m_clientAPI, clientFileName); 51 XferHandler uploader = new XferHandler(m_clientAPI, clientFileName);
52
53 return StartUpload(uploader, uploadCompleteCallback, abortCallback);
54 }
55
56 public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
57 {
58 if ((fileID == UUID.Zero) || (uploadCompleteCallback == null))
59 {
60 return false;
61 }
62
63 XferHandler uploader = new XferHandler(m_clientAPI, fileID);
64
65 return StartUpload(uploader, uploadCompleteCallback, abortCallback);
66 }
67
68 private bool StartUpload(XferHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
69 {
50 uploader.UploadDone += uploadCompleteCallback; 70 uploader.UploadDone += uploadCompleteCallback;
51 71
52 if (abortCallback != null) 72 if (abortCallback != null)
@@ -133,6 +153,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
133 mXferID = Util.GetNextXferID(); 153 mXferID = Util.GetNextXferID();
134 } 154 }
135 155
156 public XferHandler(IClientAPI pRemoteClient, UUID fileID)
157 {
158 m_asset = new AssetBase();
159 m_asset.FullID = fileID;
160 m_asset.Type = type;
161 m_asset.Data = new byte[0];
162 m_asset.Name = null;
163 m_asset.Description = "empty";
164 m_asset.Local = true;
165 m_asset.Temporary = true;
166 mXferID = Util.GetNextXferID();
167 }
168
136 public ulong XferID 169 public ulong XferID
137 { 170 {
138 get { return mXferID; } 171 get { return mXferID; }
@@ -140,7 +173,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
140 173
141 public void RequestStartXfer(IClientAPI pRemoteClient) 174 public void RequestStartXfer(IClientAPI pRemoteClient)
142 { 175 {
143 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name)); 176 if (m_asset.Name != null)
177 {
178 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, Utils.StringToBytes(m_asset.Name));
179 }
180 else
181 {
182 pRemoteClient.SendXferRequest(mXferID, m_asset.Type, m_asset.FullID, 0, new byte[0]);
183 }
144 } 184 }
145 185
146 /// <summary> 186 /// <summary>
@@ -183,7 +223,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
183 handlerUploadDone = UploadDone; 223 handlerUploadDone = UploadDone;
184 if (handlerUploadDone != null) 224 if (handlerUploadDone != null)
185 { 225 {
186 handlerUploadDone(m_asset.Name, m_asset.Data, remoteClient); 226 handlerUploadDone(m_asset.Name, m_asset.FullID, m_asset.Data, remoteClient);
187 } 227 }
188 } 228 }
189 229