예제 #1
0
 void ttclient_OnFileTransfer(FileTransfer filetransfer)
 {
     if (filetransfer.nTransferID == transferid)
     {
         if (filetransfer.nStatus == FileTransferStatus.FILETRANSFER_FINISHED)
         {
             progressBar1.Value = progressBar1.Maximum;
             timer1.Enabled = false;
         }
         else if (filetransfer.nStatus == FileTransferStatus.FILETRANSFER_ERROR)
         {
             timer1.Enabled = false;
         }
     }
 }
예제 #2
0
        void UpdateFileTransfer()
        {
            FileTransfer transfer = new FileTransfer();
            if (ttclient.GetFileTransferInfo(transferid, ref transfer))
            {
                if (transfer.nTransferred == transfer.nFileSize)
                    timer1.Enabled = false;
                filenameTextBox.Text = transfer.szRemoteFileName;
                filesizeTextBox.Text = transfer.nFileSize.ToString();

                if (transfer.nFileSize > 0)
                {
                    float percent = (float)transfer.nTransferred / (float)transfer.nFileSize;
                    progressBar1.Value = (int)(percent * 100.0f);
                }
            }
        }
예제 #3
0
 void ttclient_OnFileTransfer(FileTransfer filetransfer)
 {
     if (filetransfer.nStatus == FileTransferStatus.FILETRANSFER_ACTIVE)
         new FileTransferDlg(ttclient, filetransfer.nTransferID).Show();
 }
예제 #4
0
 /** @} */
 /** @ingroup channels
  * @brief Get information about an active file transfer.
  *
  * An active file transfer is one which has been posted through the
  * event #OnFileTransfer.
  *
  * @param nTransferID The ID of the file transfer to investigate. Transfer
  * ID is passed by #OnFileTransfer.
  * @param lpFileTransfer A preallocated struct which will receive the file
  * transfer information.
  * @see CancelFileTransfer */
 public bool GetFileTransferInfo(int nTransferID, ref FileTransfer lpFileTransfer)
 {
     return TTDLL.TT_GetFileTransferInfo(m_ttInst, nTransferID, ref lpFileTransfer);
 }
예제 #5
0
        public void TestFileUpDown()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_CREATE_TEMPORARY_CHANNEL | UserRight.USERRIGHT_UPLOAD_FILES | UserRight.USERRIGHT_DOWNLOAD_FILES;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            int cmdid;
            
            TTMessage msg = new TTMessage();

            Channel chan = new Channel();
            chan.nParentID = ttclient.GetRootChannelID();
            chan.szName = "my channel";
            chan.szTopic = "a topic";
            chan.szOpPassword = "******";
            chan.nMaxUsers = 128;
            chan.audiocodec.nCodec = Codec.OPUS_CODEC;
            chan.audiocodec.opus.nApplication = OpusConstants.OPUS_APPLICATION_AUDIO;
            chan.audiocodec.opus.nChannels = 1;
            chan.audiocodec.opus.nBitRate = 64000;
            chan.audiocodec.opus.nComplexity = 5;
            chan.audiocodec.opus.nTxIntervalMSec = 20;
            chan.audiocodec.opus.nSampleRate = 48000;
            chan.audiocodec.opus.bDTX = true;
            chan.audiocodec.opus.bFEC = true;
            chan.audiocodec.opus.bVBR = true;
            chan.audiocodec.opus.bVBRConstraint = false;

            cmdid = ttclient.DoJoinChannel(chan);
            Assert.IsTrue(cmdid > 0, "join issued");
            Assert.IsTrue(WaitCmdComplete(ttclient, cmdid, DEF_WAIT), "join complete");

            cmdid = ttclient.DoSendFile(ttclient.GetMyChannelID(), UPLOADFILE);
            Assert.IsTrue(cmdid > 0, "file upload");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg upload success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            FileTransfer tx = (FileTransfer)msg.DataToObject();
            Assert.IsFalse(tx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), tx.nChannelID);
            Assert.AreEqual(UPLOADFILE, tx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, tx.nStatus);
            FileTransfer tx2 = new FileTransfer();
            Assert.IsTrue(ttclient.GetFileTransferInfo(tx.nTransferID, ref tx2));
            Assert.AreEqual(tx.bInbound, tx2.bInbound);
            Assert.AreEqual(tx.nChannelID, tx2.nChannelID);
            Assert.AreEqual(tx.nFileSize, tx2.nFileSize);
            Assert.AreEqual(tx.nStatus, tx2.nStatus);
            Assert.AreEqual(tx.nTransferID, tx2.nTransferID);
            //Assert.AreEqual(tx.nTransferred, tx2.nTransferred);
            Assert.AreEqual(tx.szLocalFilePath, tx2.szLocalFilePath);
            Assert.AreEqual(tx.szRemoteFileName, tx2.szRemoteFileName);

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_FILE_NEW, DEF_WAIT, ref msg));
            RemoteFile file = (RemoteFile)msg.DataToObject();

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 10000, ref msg));
            tx = (FileTransfer)msg.DataToObject();

            Assert.IsFalse(tx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), tx.nChannelID);
            Assert.AreEqual(UPLOADFILE, tx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, tx.nStatus);

            RemoteFile[] files;
            Assert.IsTrue(ttclient.GetChannelFiles(ttclient.GetMyChannelID(), out files));

            RemoteFile file2 = new RemoteFile();
            Assert.IsTrue(ttclient.GetChannelFile(ttclient.GetMyChannelID(), file.nFileID, ref file2));

            Assert.AreEqual(file.nFileID, file2.nFileID);
            Assert.AreEqual(file.nFileSize, file2.nFileSize);
            Assert.AreEqual(file.szFileName, file2.szFileName);
            Assert.AreEqual(file.szUsername, file2.szUsername);

            cmdid = ttclient.DoRecvFile(ttclient.GetMyChannelID(), file.nFileID, DOWNLOADFILE);
            Assert.IsTrue(cmdid > 0, "recv issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg down success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            FileTransfer rx = (FileTransfer)msg.DataToObject();
            Assert.IsTrue(rx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), rx.nChannelID);
            Assert.AreEqual(DOWNLOADFILE, rx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, rx.nStatus);

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 10000, ref msg));
            rx = (FileTransfer)msg.DataToObject();

            Assert.IsTrue(rx.bInbound);
            Assert.AreEqual(ttclient.GetMyChannelID(), rx.nChannelID);
            Assert.AreEqual(DOWNLOADFILE, rx.szLocalFilePath);
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_FINISHED, rx.nStatus);

            cmdid = ttclient.DoRecvFile(ttclient.GetMyChannelID(), file.nFileID, DOWNLOADFILE);
            Assert.IsTrue(cmdid > 0, "recv issued");
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "reg down success");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_FILETRANSFER, 2000, ref msg));

            rx = (FileTransfer)msg.DataToObject();
            Assert.AreEqual(FileTransferStatus.FILETRANSFER_ACTIVE, rx.nStatus);
            Assert.IsTrue(ttclient.CancelFileTranfer(rx.nTransferID));

            cmdid = ttclient.DoDeleteFile(ttclient.GetMyChannelID(), file.nFileID);
            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_CMD_SUCCESS, DEF_WAIT, ref msg), "delete file success");
        }
예제 #6
0
 private void FileTransferDlg_FormClosing(object sender, FormClosingEventArgs e)
 {
     FileTransfer transfer = new FileTransfer();
     if (ttclient.GetFileTransferInfo(transferid, ref transfer))
         ttclient.CancelFileTranfer(transferid);
 }