Migrate dcc bouncing to its own module

This commit is contained in:
Kyle Fuller
2011-04-02 22:50:24 +01:00
parent 0b360c0102
commit 8f508cb4a5
13 changed files with 482 additions and 529 deletions
-48
View File
@@ -9,7 +9,6 @@
#include "IRCSock.h"
#include "Chan.h"
#include "Client.h"
#include "DCCBounce.h"
#include "User.h"
#include "znc.h"
@@ -768,53 +767,6 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) {
sMessage = "ACTION " + sMessage;
}
if (sMessage.Equals("DCC ", false, 4) && m_pUser && m_pUser->BounceDCCs() && m_pUser->IsUserAttached()) {
// DCC CHAT chat 2453612361 44592
CString sType = sMessage.Token(1);
CString sFile = sMessage.Token(2);
unsigned long uLongIP = sMessage.Token(3).ToULong();
unsigned short uPort = sMessage.Token(4).ToUShort();
unsigned long uFileSize = sMessage.Token(5).ToULong();
if (sType.Equals("CHAT")) {
CNick FromNick(Nick.GetNickMask());
unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, m_pUser, CUtils::GetIP(uLongIP));
if (uBNCPort) {
CString sIP = m_pUser->GetLocalDCCIP();
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001");
}
} else if (sType.Equals("SEND")) {
// DCC SEND readme.txt 403120438 5550 1104
unsigned short uBNCPort = CDCCBounce::DCCRequest(Nick.GetNick(), uLongIP, uPort, sFile, false, m_pUser, CUtils::GetIP(uLongIP));
if (uBNCPort) {
CString sIP = m_pUser->GetLocalDCCIP();
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001");
}
} else if (sType.Equals("RESUME")) {
// Need to lookup the connection by port, filter the port, and forward to the user
CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(sMessage.Token(3).ToUShort());
if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
}
} else if (sType.Equals("ACCEPT")) {
// Need to lookup the connection by port, filter the port, and forward to the user
CSockManager& Manager = CZNC::Get().GetManager();
for (unsigned int a = 0; a < Manager.size(); a++) {
CDCCBounce* pSock = (CDCCBounce*) Manager[a];
if (pSock && pSock->GetSockName().Equals("DCC::", false, 5)) {
if (pSock->GetUserPort() == sMessage.Token(3).ToUShort()) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
}
}
}
}
return true;
}
// This handles everything which wasn't handled yet
return OnGeneralCTCP(Nick, sMessage);
}