示例#1
0
BOOL CIrcProto::CList_AddDCCChat(const CMString& name, const CMString& hostmask, unsigned long adr, int port)
{
	MCONTACT hContact;
	TCHAR szNick[256];
	char szService[256];
	bool bFlag = false;

	CONTACT usertemp = { (TCHAR*)name.c_str(), NULL, NULL, false, false, true };
	MCONTACT hc = CList_FindContact(&usertemp);
	if (hc && db_get_b(hc, "CList", "NotOnList", 0) == 0 && db_get_b(hc, "CList", "Hidden", 0) == 0)
		bFlag = true;

	CMString contactname = name; contactname += DCCSTRING;

	CONTACT user = { (TCHAR*)contactname.c_str(), NULL, NULL, false, false, true };
	hContact = CList_AddContact(&user, false, false);
	setByte(hContact, "DCC", 1);

	DCCINFO* pdci = new DCCINFO;
	pdci->sHostmask = hostmask;
	pdci->hContact = hContact;
	pdci->dwAdr = (DWORD)adr;
	pdci->iPort = port;
	pdci->iType = DCC_CHAT;
	pdci->bSender = false;
	pdci->sContactName = name;

	if (m_DCCChatAccept == 3 || m_DCCChatAccept == 2 && bFlag) {
		CDccSession* dcc = new CDccSession(this, pdci);

		CDccSession* olddcc = FindDCCSession(hContact);
		if (olddcc)
			olddcc->Disconnect();

		AddDCCSession(hContact, dcc);
		dcc->Connect();
		if (getByte("MirVerAutoRequest", 1))
			PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), name.c_str());
	}
	else {
		CLISTEVENT cle = { sizeof(cle) };
		cle.hContact = hContact;
		cle.hDbEvent = (HANDLE)"dccchat";
		cle.flags = CLEF_TCHAR;
		cle.hIcon = LoadIconEx(IDI_DCC);
		mir_snprintf(szService, sizeof(szService), "%s/DblClickEvent", m_szModuleName);
		cle.pszService = szService;
		mir_sntprintf(szNick, SIZEOF(szNick), TranslateT("CTCP chat request from %s"), name.c_str());
		cle.ptszTooltip = szNick;
		cle.lParam = (LPARAM)pdci;

		if (CallService(MS_CLIST_GETEVENT, hContact, 0))
			CallService(MS_CLIST_REMOVEEVENT, hContact, (LPARAM)"dccchat");
		CallService(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle);
	}
	return TRUE;
}
示例#2
0
void CIrcProto::CheckDCCTimeout(void)
{
	mir_cslock lck(m_dcc);

	for (int i = 0; i < m_dcc_chats.getCount(); i++) {
		CDccSession* p = m_dcc_chats[i];
		if (time(0) > p->tLastActivity + DCCCHATTIMEOUT)
			p->Disconnect();
	}

	for (int j = 0; j < m_dcc_xfers.getCount(); j++) {
		CDccSession* p = m_dcc_xfers[j];
		if (time(0) > p->tLastActivity + DCCSENDTIMEOUT)
			p->Disconnect();
	}
}
示例#3
0
void CIrcProto::CheckDCCTimeout(void)
{
	EnterCriticalSection(&m_dcc);

	for ( int i=0; i < m_dcc_chats.getCount(); i++ ) {
		CDccSession* p = m_dcc_chats[i];
		if ( time(0) > p->tLastActivity + DCCCHATTIMEOUT )
			p->Disconnect();
	}

	for ( int j=0; j < m_dcc_xfers.getCount(); j++ ) {
		CDccSession* p = m_dcc_xfers[j];
		if ( time(0) > p->tLastActivity + DCCSENDTIMEOUT )
			p->Disconnect();
	}

	LeaveCriticalSection(&m_dcc);
}