public override void BeginSending(Transfer transfer, byte[] aesKey, byte[] aesIv)
        {
            CurrentTransfer = transfer;
            AbortCurrentTransfer = false;

            TransferThread = new Thread(TransferSend);
            TransferThread.Start();
        }
Esempio n. 2
0
        public void Enqueue(Transfer trans)
        {
            Queue.Add(trans);

            if (CurrentTransfer == null)
            {
                CurrentTransfer = trans;
                StartFileTransfer(CurrentTransfer);
            }
        }
Esempio n. 3
0
 void StartFileTransfer(Transfer trans)
 {
     try
     {
         Connection.StartFileTransfer(trans);
     }
     catch (Exception ex)
     {
         ex.Handle();
         _connection_FileTransferEnded(trans, false, false);
     }
 }
Esempio n. 4
0
        void _connection_FileTransferEnded(Transfer trans, bool success, bool aborted)
        {
            if (Queue.Contains(trans))
                Queue.Remove(trans);

            if (!success)
            {
                if (!aborted)
                {
                    // File Transfer Error
                    if (FileTransferFailed != null)
                        FileTransferFailed(trans);
                }

                CurrentTransfer = null;
                Abort();

                return;
            }

            if (Queue.Count > 0)
            {
                CurrentTransfer = Queue[0];
                StartFileTransfer(CurrentTransfer);
            }
            else
            {
                CurrentTransfer = null;
            }
        }
Esempio n. 5
0
 public void RaiseFileTransferEnded(Transfer trans, bool success, bool aborted)
 {
     UIThreadSyncContext.Send(new System.Threading.SendOrPostCallback(state =>
     {
         if (FileTransferEnded != null)
             FileTransferEnded(trans, success, aborted);
     }), null);
 }
Esempio n. 6
0
        /// <summary>
        /// Start a transfer
        /// </summary>
        /// <param name="transfer"></param>
        public void StartFileTransfer(Transfer transfer)
        {
            var req = transfer.GenerateRequest();

            if (ConnectionSocket != null)
            {
                // Send transfer request
                TEBPProvider.Send(req, response =>
                {
                    if (response.Accepted)
                    {
                        Console.WriteLine("Server accepted FileTransferRequest.");
                        FileTransferResponse res = response as FileTransferResponse;

                        DataConnection = SingleTransferSender.ConnectTo(res.DataConnectionAddress, res.DataConnectionPort);
                        if (DataConnection == null)
                            throw new ConnectionException("Could not establish data connection.");
                        DataConnection.ParentConnection = this;

                        DataConnection.BeginSending(transfer, res.AesKey, res.AesIv);
                    }
                    else if (response is TrivialEntityBasedProtocol.DefaultEntities.NoResponse)
                    {
                        RaiseFileTransferEnded(transfer, false, false);
                    }
                });
            }
            else
            {
                // Special mode.
                DataConnection = new SingleTransferSenderSpecial();
                DataConnection.ParentConnection = this;
                DataConnection.BeginSending(transfer, null, null);
            }
        }
Esempio n. 7
0
        void DoTransfer(Transfer trans)
        {
            trans.Context = this;
            transfers.Enqueue(trans);

            StartReloadingCurrentTransferView();
        }
Esempio n. 8
0
 void transfers_FileTransferFailed(Transfer transfer)
 {
     this.ShowToast(string.Format(GetString(Resource.String.ErrTransferFailedFormatStr), transfer.FileName));
 }