void ttclient_OnCmdFileRemove(RemoteFile remotefile) { if (ttclient.GetMyChannelID() != remotefile.nChannelID) return; foreach (ListViewItem item in listview.Items) if ((int)item.Tag == remotefile.nFileID) listview.Items.Remove(item); }
void ttclient_OnCmdFileNew(RemoteFile remotefile) { if (ttclient.GetMyChannelID() != remotefile.nChannelID) return;//an admin can see all files but we don't show it here (for now) ListViewItem item = new ListViewItem(); item.Tag = remotefile.nFileID; item.Text = remotefile.nFileID.ToString(); item.SubItems.Add(remotefile.szFileName); item.SubItems.Add(remotefile.nFileSize.ToString()); item.SubItems.Add(remotefile.szUsername); listview.Items.Add(item); }
public static extern BearWare.ClientError TTS_AddFileToChannel(IntPtr lpTTSInstance, [In] ref string szLocalFilePath, [In] ref BearWare.RemoteFile lpRemoteFile);
public static extern BearWare.ClientError TTS_RemoveFileFromChannel(IntPtr lpTTSInstance, [In] ref BearWare.RemoteFile lpRemoteFile);
private void downloadFileToolStripMenuItem_Click(object sender, EventArgs e) { int fileid = files.GetSelectedFile(); int channelid = files.GetSelectedChannel(); RemoteFile file = new RemoteFile(); if (!ttclient.GetChannelFile(channelid, fileid, ref file)) return; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.FileName = file.szFileName; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) ttclient.DoRecvFile(channelid, fileid, saveFileDialog1.FileName); }
/** * @brief Get the list of the files in a channel which can be * downloaded. * * @param nChannelID The ID of the channel to extract the files from. * @param lpRemoteFiles A array of #BearWare.RemoteFile which will receive * file information. * @see TeamTalk.GetChannelFile */ public bool GetChannelFiles(int nChannelID, out RemoteFile[] lpRemoteFiles) { int count = 0; bool b = TTDLL.TT_GetChannelFiles_NULL(m_ttInst, nChannelID, IntPtr.Zero, ref count); RemoteFile[] files = new RemoteFile[count]; b = TTDLL.TT_GetChannelFiles(m_ttInst, nChannelID, files, ref count); lpRemoteFiles = b ? files : null; return b; }
/** * @brief Get information about a file which can be downloaded. * * @param nChannelID The ID of the channel to extract the file from. * @param nFileID The ID of the file. * @param lpRemoteFile A preallocated struct which will receive * file information. */ public bool GetChannelFile(int nChannelID, int nFileID, ref RemoteFile lpRemoteFile) { return TTDLL.TT_GetChannelFile(m_ttInst, nChannelID, nFileID, ref lpRemoteFile); }
void ttserver_OnFileUploaded(ref RemoteFile lpRemoteFile, ref User lpUser) { String str = String.Format("File {0} uploaded to channel #{1}", lpRemoteFile.szFileName, lpRemoteFile.nChannelID); Console.WriteLine(str); }
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"); }
static void ttclient_OnCmdFileNew(RemoteFile fileinfo) { string chanpath = ""; if (ttclient.GetChannelPath(fileinfo.nChannelID, ref chanpath)) Console.WriteLine("File #{0} {1} added to channel {2}", fileinfo.nFileID, fileinfo.szFileName, chanpath); }