Exemplo n.º 1
0
        private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            uploader.UploadDone += uploadCompleteCallback;
            uploader.UploadDone += RemoveXferUploadHandler;

            if (abortCallback != null)
            {
                uploader.UploadAborted += abortCallback;
            }

            lock (m_uploadHandlersLock)
            {
                if (!m_uploadHandlers.ContainsKey(uploader.XferID))
                {
                    m_uploadHandlers.Add(uploader.XferID, uploader);
                    uploader.RequestStartXfer(m_clientAPI);
                    return(true);
                }
                else
                {
                    // something went wrong with the xferID allocation
                    uploader.UploadDone -= uploadCompleteCallback;
                    uploader.UploadDone -= RemoveXferUploadHandler;
                    if (abortCallback != null)
                    {
                        uploader.UploadAborted -= abortCallback;
                    }
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            if ((fileID == UUID.Zero) || (uploadCompleteCallback == null))
            {
                return(false);
            }

            XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID);

            return(StartUpload(uploader, uploadCompleteCallback, abortCallback));
        }
Exemplo n.º 3
0
        public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null))
            {
                return(false);
            }

            XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName);

            return(StartUpload(uploader, uploadCompleteCallback, abortCallback));
        }
Exemplo n.º 4
0
        public bool RequestUpload(UUID fileID, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            if ((fileID == UUID.Zero) || (uploadCompleteCallback == null))
            {
                return false;
            }

            XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, fileID);

            return StartUpload(uploader, uploadCompleteCallback, abortCallback);
        }
Exemplo n.º 5
0
        public bool RequestUpload(string clientFileName, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            if ((String.IsNullOrEmpty(clientFileName)) || (uploadCompleteCallback == null))
            {
                return false;
            }

            XferUploadHandler uploader = new XferUploadHandler(m_clientAPI, clientFileName);

            return StartUpload(uploader, uploadCompleteCallback, abortCallback);
        }
Exemplo n.º 6
0
        private bool StartUpload(XferUploadHandler uploader, UploadComplete uploadCompleteCallback, UploadAborted abortCallback)
        {
            uploader.UploadDone += uploadCompleteCallback;
            uploader.UploadDone += RemoveXferUploadHandler;

            if (abortCallback != null)
            {
                uploader.UploadAborted += abortCallback;
            }

            lock (m_uploadHandlersLock)
            {
                if (!m_uploadHandlers.ContainsKey(uploader.XferID))
                {
                    m_uploadHandlers.Add(uploader.XferID, uploader);
                    uploader.RequestStartXfer(m_clientAPI);
                    return true;
                }
                else
                {
                    // something went wrong with the xferID allocation
                    uploader.UploadDone -= uploadCompleteCallback;
                    uploader.UploadDone -= RemoveXferUploadHandler;
                    if (abortCallback != null)
                    {
                        uploader.UploadAborted -= abortCallback;
                    }
                    return false;
                }
            }
        }