本文整理汇总了C++中CDCCMod::PutModule方法的典型用法代码示例。如果您正苦于以下问题:C++ CDCCMod::PutModule方法的具体用法?C++ CDCCMod::PutModule怎么用?C++ CDCCMod::PutModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDCCMod
的用法示例。
在下文中一共展示了CDCCMod::PutModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Disconnected
void CDCCSock::Disconnected() {
const CString sStart = ((m_bSend) ? "DCC -> [" : "DCC <- [") +
m_sRemoteNick + "][" + m_sFileName + "] - ";
DEBUG(GetSockName() << " == Disconnected()");
if (m_uBytesSoFar > m_uFileSize) {
if (m_bSend) {
m_pModule->PutModule(t_f("Sending [{1}] to [{2}]: Too much data!")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Too much data!")(
m_sFileName, m_sRemoteNick));
}
} else if (m_uBytesSoFar == m_uFileSize) {
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}] completed at {3} KiB/s")(
m_sFileName, m_sRemoteNick,
static_cast<int>(GetAvgWrite() / 1024.0)));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}] completed at {3} KiB/s")(
m_sFileName, m_sRemoteNick,
static_cast<int>(GetAvgRead() / 1024.0)));
}
} else {
m_pModule->PutModule(sStart + "Incomplete!");
}
}
示例2: SendPacket
void CDCCSock::SendPacket() {
if (!m_pFile) {
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - File closed prematurely.");
Close();
return;
}
if (GetInternalWriteBuffer().size() > 1024 * 1024) {
// There is still enough data to be written, don't add more
// stuff to that buffer.
DEBUG("SendPacket(): Skipping send, buffer still full enough [" << GetInternalWriteBuffer().size() << "]["
<< m_sRemoteNick << "][" << m_sFileName << "]");
return;
}
char szBuf[4096];
int iLen = m_pFile->Read(szBuf, 4096);
if (iLen < 0) {
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Error reading from file.");
Close();
return;
}
if (iLen > 0) {
Write(szBuf, iLen);
m_uBytesSoFar += iLen;
}
}
示例3: Timeout
void CDCCSock::Timeout() {
DEBUG(GetSockName() << " == Timeout()");
if (m_bSend) {
m_pModule->PutModule(t_f("Sending [{1}] to [{2}]: Timeout.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Timeout.")(
m_sFileName, m_sRemoteNick));
}
}
示例4: ConnectionRefused
void CDCCSock::ConnectionRefused() {
DEBUG(GetSockName() << " == ConnectionRefused()");
if (m_bSend) {
m_pModule->PutModule(t_f("Sending [{1}] to [{2}]: Connection refused.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Connection refused.")(
m_sFileName, m_sRemoteNick));
}
}
示例5: SockError
void CDCCSock::SockError(int iErrno, const CString& sDescription) {
DEBUG(GetSockName() << " == SockError(" << iErrno << ", " << sDescription
<< ")");
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Socket error {3}: {4}")(
m_sFileName, m_sRemoteNick, iErrno, sDescription));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Socket error {3}: {4}")(
m_sFileName, m_sRemoteNick, iErrno, sDescription));
}
}
示例6: SendPacket
void CDCCSock::SendPacket() {
if (!m_pFile) {
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: File closed prematurely.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: File closed prematurely.")(
m_sFileName, m_sRemoteNick));
}
Close();
return;
}
if (GetInternalWriteBuffer().size() > 1024 * 1024) {
// There is still enough data to be written, don't add more
// stuff to that buffer.
DEBUG("SendPacket(): Skipping send, buffer still full enough ["
<< GetInternalWriteBuffer().size() << "][" << m_sRemoteNick
<< "][" << m_sFileName << "]");
return;
}
char szBuf[4096];
ssize_t iLen = m_pFile->Read(szBuf, 4096);
if (iLen < 0) {
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Error reading from file.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Error reading from file.")(
m_sFileName, m_sRemoteNick));
}
Close();
return;
}
if (iLen > 0) {
Write(szBuf, iLen);
m_uBytesSoFar += iLen;
}
}
示例7: Connected
void CDCCSock::Connected() {
DEBUG(GetSockName() << " == Connected(" << GetRemoteIP() << ")");
if (m_bSend) {
m_pModule->PutModule(t_f("Sending [{1}] to [{2}]: Transfer started.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Transfer started.")(
m_sFileName, m_sRemoteNick));
}
if (m_bSend) {
SendPacket();
}
SetTimeout(120);
}
示例8: ReadData
void CDCCSock::ReadData(const char* data, size_t len) {
if (!m_pFile) {
DEBUG("File not open! closing get.");
if (m_bSend) {
m_pModule->PutModule(t_f("Sending [{1}] to [{2}]: File not open!")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: File not open!")(
m_sFileName, m_sRemoteNick));
}
Close();
return;
}
// DCC specs says the receiving end sends the number of bytes it
// received so far as a 4 byte integer in network byte order, so we need
// uint32_t to do the job portably. This also means that the maximum
// file that we can transfer is 4 GiB big (see OpenFile()).
if (m_bSend) {
m_sSendBuf.append(data, len);
while (m_sSendBuf.size() >= 4) {
uint32_t iRemoteSoFar;
memcpy(&iRemoteSoFar, m_sSendBuf.data(), sizeof(iRemoteSoFar));
iRemoteSoFar = ntohl(iRemoteSoFar);
if ((iRemoteSoFar + 65536) >= m_uBytesSoFar) {
SendPacket();
}
m_sSendBuf.erase(0, 4);
}
} else {
m_pFile->Write(data, len);
m_uBytesSoFar += len;
uint32_t uSoFar = htonl((uint32_t)m_uBytesSoFar);
Write((char*)&uSoFar, sizeof(uSoFar));
if (m_uBytesSoFar >= m_uFileSize) {
Close();
}
}
}
示例9: Disconnected
void CDCCSock::Disconnected() {
const CString sStart = ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - ";
DEBUG(GetSockName() << " == Disconnected()");
if (m_uBytesSoFar > m_uFileSize) {
m_pModule->PutModule(sStart + "TooMuchData!");
} else if (m_uBytesSoFar == m_uFileSize) {
if (m_bSend) {
m_pModule->PutModule(sStart + "Completed! - Sent [" + m_sLocalFile +
"] at [" + CString((int) (GetAvgWrite() / 1024.0)) + " KiB/s ]");
} else {
m_pModule->PutModule(sStart + "Completed! - Saved to [" + m_sLocalFile +
"] at [" + CString((int) (GetAvgRead() / 1024.0)) + " KiB/s ]");
}
} else {
m_pModule->PutModule(sStart + "Incomplete!");
}
}
示例10: Connected
void CDCCSock::Connected() {
DEBUG(GetSockName() << " == Connected(" << GetRemoteIP() << ")");
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Transfer Started.");
if (m_bSend) {
SendPacket();
}
SetTimeout(120);
}
示例11: OpenFile
CFile* CDCCSock::OpenFile(bool bWrite) {
if ((m_pFile) || (m_sLocalFile.empty())) {
m_pModule->PutModule(((bWrite) ? "DCC <- [" : "DCC -> [") + m_sRemoteNick + "][" + m_sLocalFile + "] - Unable to open file.");
return NULL;
}
m_pFile = new CFile(m_sLocalFile);
if (bWrite) {
if (m_pFile->Exists()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - File already exists [" + m_sLocalFile + "]");
return NULL;
}
if (!m_pFile->Open(O_WRONLY | O_TRUNC | O_CREAT)) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]");
return NULL;
}
} else {
if (!m_pFile->IsReg()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Not a file [" + m_sLocalFile + "]");
return NULL;
}
if (!m_pFile->Open()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]");
return NULL;
}
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
if (uFileSize > (unsigned long long) 0xffffffff) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - File too large (>4 GiB) [" + m_sLocalFile + "]");
return NULL;
}
m_uFileSize = (unsigned long) uFileSize;
}
m_sFileName = m_pFile->GetShortName();
return m_pFile;
}
示例12: OpenFile
CFile* CDCCSock::OpenFile(bool bWrite) {
if ((m_pFile) || (m_sLocalFile.empty())) {
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Unable to open file.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Unable to open file.")(
m_sFileName, m_sRemoteNick));
}
return nullptr;
}
m_pFile = new CFile(m_sLocalFile);
if (bWrite) {
if (m_pFile->Exists()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: File already exists.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
if (!m_pFile->Open(O_WRONLY | O_TRUNC | O_CREAT)) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Could not open file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
} else {
if (!m_pFile->IsReg()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Not a file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
if (!m_pFile->Open()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Could not open file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
if (uFileSize > (unsigned long long)0xffffffffULL) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: File too large (>4 GiB).")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
m_uFileSize = uFileSize;
}
m_sFileName = m_pFile->GetShortName();
return m_pFile;
}
示例13: SockError
void CDCCSock::SockError(int iErrno) {
DEBUG(GetSockName() << " == SockError(" << iErrno << ")");
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Socket Error [" + CString(iErrno) + "]");
}
示例14: Timeout
void CDCCSock::Timeout() {
DEBUG(GetSockName() << " == Timeout()");
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Timed Out.");
}
示例15: ConnectionRefused
void CDCCSock::ConnectionRefused() {
DEBUG(GetSockName() << " == ConnectionRefused()");
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Connection Refused.");
}