Пример #1
0
void CChatSelector::ConnectingResult(CUpDownClient* sender, bool bSuccess)
{
	CChatItem	*pChatItem = GetItemByClient(sender);

	if (pChatItem == NULL || pChatItem->m_pClient == NULL)
		return;

	pChatItem->m_pClient->SetChatState(MS_CHATTING);

	if (!bSuccess)
	{
		if (!pChatItem->m_strMessagePending.IsEmpty())
		{
			pChatItem->m_pLog->AppendText(_T(' ') + GetResString(IDS_FAILED) + _T('\n'), RGB(255, 0, 0));
			pChatItem->m_strMessagePending.Empty();
		}
#ifdef _DEBUG
		else
			pChatItem->m_pLog->AppendText(GetResString(IDS_CHATDISCONNECTED) + _T('\n'), RGB(255, 0, 0));
#endif
	}
	else if (!pChatItem->m_strMessagePending.IsEmpty())
	{
		pChatItem->m_pLog->AppendText(_T(" ok\n"), RGB(255, 0, 0));
		SendMessagePacket(*pChatItem, pChatItem->m_strMessagePending);

		COleDateTime	timelog(COleDateTime::GetCurrentTime());
		CString			strTmp;

		strTmp.Format(_T("%s (%s): "), g_App.m_pPrefs->GetUserNick(), timelog.Format(_T("%c")));
		pChatItem->m_pLog->AppendText(strTmp, RGB(1, 180, 20));
		pChatItem->m_pLog->AppendText(pChatItem->m_strMessagePending + _T('\n'));
		pChatItem->m_strMessagePending.Empty();
	}
}
Пример #2
0
void CChatSelector::ClientObjectChanged(CUpDownClient* pOldClient, CUpDownClient* pNewClient){
	// the friend has deceided to change the clients objects (because the old doesnt seems to be our friend) during a connectiontry
	// in order to not close and reopen a new session and loose the prior chat, switch the objects on a existing tab
	// nothing else changes since the tab is supposed to be still connected to the same friend
	CChatItem* ci = GetItemByClient(pOldClient);
	if (!ci)
		return;
	ci->client = pNewClient;
}
Пример #3
0
void CChatSelector::ReportConnectionProgress(CUpDownClient* pClient, CString strProgressDesc, bool bNoTimeStamp)
{
	CChatItem* ci = GetItemByClient(pClient);
	if (!ci)
		return;
	if (thePrefs.GetIRCAddTimeStamp() && !bNoTimeStamp)
		AddTimeStamp(ci);
	ci->log->AppendKeyWord(strProgressDesc, STATUS_MSG_COLOR);
}
Пример #4
0
void CChatSelector::ShowCaptchaResult(CUpDownClient* sender, CString strResult)
{
	CChatItem* ci = GetItemByClient(sender);
	if (ci != NULL)
	{
		if (thePrefs.GetIRCAddTimeStamp())
			AddTimeStamp(ci);
		ci->log->AppendKeyWord(_T("*** ") + strResult + _T("\n"), STATUS_MSG_COLOR);
	}
}
Пример #5
0
void CChatSelector::ShowCaptchaRequest(CUpDownClient* sender, HBITMAP bmpCaptcha)
{
	CChatItem* ci = GetItemByClient(sender);
	if (ci != NULL)
	{
		if (thePrefs.GetIRCAddTimeStamp())
			AddTimeStamp(ci);
		ci->log->AppendKeyWord(_T("*** ") + GetResString(IDS_CAPTCHAREQUEST), STATUS_MSG_COLOR);
		ci->log->AddCaptcha(bmpCaptcha);
		ci->log->AddLine(_T("\n"));
	}
}
Пример #6
0
void CChatSelector::ConnectingResult(CUpDownClient* sender, bool success)
{
	CChatItem* ci = GetItemByClient(sender);
	if (!ci)
		return;

	ci->client->SetChatState(MS_CHATTING);
	if (!success){
		if (!ci->strMessagePending.IsEmpty()){
			ci->log->AppendKeyWord(_T(" ") + GetResString(IDS_FAILED) + _T("\n"), RGB(255,0,0));
			ci->strMessagePending.Empty();
		}
		else{
//==>timestamp in chatwindow [shadow2004]
			if (thePrefs.GetIRCAddTimestamp())
				AddTimeStamp(ci);
//<==timestamp in chatwindow [shadow2004]
			ci->log->AppendKeyWord(GetResString(IDS_CHATDISCONNECTED) + _T("\n"), RGB(255,0,0));
		}
	}
	else if (!ci->strMessagePending.IsEmpty()){
		ci->log->AppendKeyWord(_T(" ok\n"), RGB(255,0,0));
		
		CSafeMemFile data;
		data.WriteString(ci->strMessagePending, ci->client->GetUnicodeSupport());
		Packet* packet = new Packet(&data, OP_EDONKEYPROT, OP_MESSAGE);
		theStats.AddUpDataOverheadOther(packet->size);
		ci->client->socket->SendPacket(packet, true, true);

//==>timestamp in chatwindow [shadow2004]
		if (thePrefs.GetIRCAddTimestamp())
			AddTimeStamp(ci);
//<==timestamp in chatwindow [shadow2004]
		ci->log->AppendKeyWord(thePrefs.GetUserNick(), RGB(1,180,20));
		ci->log->AppendText(_T(": "));
		ci->log->AppendText(ci->strMessagePending + _T("\n"));
		
		ci->strMessagePending.Empty();
	}
	else{
//==>timestamp in chatwindow [shadow2004]
		if (thePrefs.GetIRCAddTimestamp())
			AddTimeStamp(ci);
//==>timestamp in chatwindow [shadow2004]
		ci->log->AppendKeyWord(_T("*** Connected\n"), RGB(255,0,0));
	}
}
Пример #7
0
void CChatSelector::ProcessMessage(CUpDownClient* sender, const CString& message)
{
	sender->IncMessagesReceived();
	CChatItem* ci = GetItemByClient(sender);

	AddLogLine(true, GetResString(IDS_NEWMSG), sender->GetUserName(), ipstr(sender->GetConnectIP()));
	
	bool isNewChatWindow = false;
	if (!ci)
	{
		if ((UINT)GetItemCount() >= thePrefs.GetMsgSessionsMax())
			return;
		ci = StartSession(sender, false);
		isNewChatWindow = true; 
	}
	if (thePrefs.GetIRCAddTimeStamp())
		AddTimeStamp(ci);
	ci->log->AppendKeyWord(sender->GetUserName(), RECV_SOURCE_MSG_COLOR);
	ci->log->AppendText(_T(": "));
	ci->log->AppendText(message + _T("\n"));
	int iTabItem = GetTabByClient(sender);
	if (GetCurSel() == iTabItem && GetParent()->IsWindowVisible())
	{
		// chat window is already visible
		;
	}
	else if (GetCurSel() != iTabItem)
	{
		// chat window is already visible, but tab is not selected
		ci->notify = true;
	}
	else
	{
		ci->notify = true;
        if (isNewChatWindow || thePrefs.GetNotifierOnEveryChatMsg())
			theApp.emuledlg->ShowNotifier(GetResString(IDS_TBN_NEWCHATMSG) + _T(" ") + CString(sender->GetUserName()) + _T(":'") + message + _T("'\n"), TBN_CHAT);
		isNewChatWindow = false;
	}
}
Пример #8
0
void CChatSelector::ConnectingResult(CUpDownClient* sender, bool success)
{
	CChatItem* ci = GetItemByClient(sender);
	if (!ci)
		return;

	ci->client->SetChatState(MS_CHATTING);
	if (!success){
		if (!ci->strMessagePending.IsEmpty()){
			ci->log->AppendKeyWord(_T(" ...") + GetResString(IDS_FAILED) + _T("\n"), STATUS_MSG_COLOR);
			ci->strMessagePending.Empty();
		}
		else{
			if (thePrefs.GetIRCAddTimeStamp())
				AddTimeStamp(ci);
			ci->log->AppendKeyWord(GetResString(IDS_CHATDISCONNECTED) + _T("\n"), STATUS_MSG_COLOR);
		}
	}
	else if (!ci->strMessagePending.IsEmpty()){
		ci->log->AppendKeyWord(_T(" ...") + GetResString(IDS_TREEOPTIONS_OK) + _T("\n"), STATUS_MSG_COLOR);
		ci->client->SendChatMessage(ci->strMessagePending);

		if (thePrefs.GetIRCAddTimeStamp())
			AddTimeStamp(ci);
		ci->log->AppendKeyWord(thePrefs.GetUserNick(), SENT_TARGET_MSG_COLOR);
		ci->log->AppendText(_T(": "));
		ci->log->AppendText(ci->strMessagePending + _T("\n"));
		
		ci->strMessagePending.Empty();
	}
	else{
		if (thePrefs.GetIRCAddTimeStamp())
			AddTimeStamp(ci);
		ci->log->AppendKeyWord(_T("*** Connected\n"), STATUS_MSG_COLOR);
	}
}
Пример #9
0
void CChatSelector::ProcessMessage(CUpDownClient* sender, const CString& message)
{
	sender->IncMessagesReceived();

	CString strMessage(message);
	strMessage.MakeLower();
	CString resToken;
	int curPos = 0;
	resToken = thePrefs.GetMessageFilter().Tokenize(_T("|"), curPos);
	while (!resToken.IsEmpty())
	{
		resToken.Trim();
		if (strMessage.Find(resToken.MakeLower()) > -1)
			return;
		resToken = thePrefs.GetMessageFilter().Tokenize(_T("|"), curPos);
	}

	CChatItem* ci = GetItemByClient(sender);

	// advanced spamfilter check
	if (IsSpam(strMessage, sender))
	{
		if (!sender->IsSpammer()){
			if (thePrefs.GetVerbose())
				AddDebugLogLine(false, _T("'%s' has been marked as spammer"), sender->GetUserName());
		}
		sender->SetSpammer(true);
		if (ci)
			EndSession(sender);
		return;
	}

	bool isNewChatWindow = false;
	if (!ci)
	{
		if (GetItemCount() >= thePrefs.GetMsgSessionsMax())
			return;
		ci = StartSession(sender, false);
		isNewChatWindow = true; 
	}
//==>timestamp in chatwindow [shadow2004]
	if (thePrefs.GetIRCAddTimestamp())
		AddTimeStamp(ci);
//<==timestamp in chatwindow [shadow2004]
	ci->log->AppendKeyWord(sender->GetUserName(), RGB(50,200,250));
	ci->log->AppendText(_T(": "));
	ci->log->AppendText(message + _T("\n"));
	int iTabItem = GetTabByClient(sender);
	if (GetCurSel() == iTabItem && GetParent()->IsWindowVisible())
	{
		// chat window is already visible
		;
	}
	else if (GetCurSel() != iTabItem)
	{
		// chat window is already visible, but tab is not selected
		ci->notify = true;
	}
	else
	{
		ci->notify = true;
        if (isNewChatWindow || thePrefs.GetNotifierPopsEveryChatMsg())
			theApp.emuledlg->ShowNotifier(GetResString(IDS_TBN_NEWCHATMSG) + _T(" ") + CString(sender->GetUserName()) + _T(":'") + message + _T("'\n"), TBN_CHAT);
		isNewChatWindow = false;
	}
}
Пример #10
0
void CChatSelector::ProcessMessage(CUpDownClient* pSender, const CString &strIncomingMessage)
{
	CString	strMessage = strIncomingMessage;
	int		iCurPos = 0;

	strMessage.MakeLower();

//	Ban spammers
	if ( g_App.m_pPrefs->IsCounterMeasures() &&
		( strMessage.Find(_T("di-emule")) >= 0
		|| strMessage.Find(_T("emule fx")) >= 0
		|| strMessage.Find(_T("zambor")) >= 0
		|| strMessage.Find(_T("fastest emule ever")) >= 0
		|| strMessage.Find(_T("robot from riaa")) >= 0
		|| strMessage.Find(_T("ketamine")) >= 0
		|| strMessage.Find(_T("http://www.chez.com/theworld/")) >= 0
		|| strMessage.Find(_T("http://fullspeed.to/mison")) >= 0 ) )
	{
		AddDebugLogLine(RGB_LOG_DIMMED_TXT _T("Anti-leechermods: Client %s has been banned because of spamming"), pSender->GetClientNameWithSoftware());
		pSender->Ban(BAN_CLIENT_SPAMMING);
		return;
	}

	CString	strResToken, strFilter = g_App.m_pPrefs->GetMessageFilter();

	strFilter.MakeLower();
	for (;;)
	{
		strResToken = strFilter.Tokenize(_T("|"), iCurPos);
		if (strResToken.IsEmpty())
			break;
		if (strMessage.Find(strResToken) >= 0)
		{
			AddDebugLogLine(RGB_LOG_DIMMED_TXT _T("Filtered message '%s' from client %s"), strIncomingMessage, pSender->GetClientNameWithSoftware());
			return;
		}
	}

	CChatItem	*pChatItem = GetItemByClient(pSender);
	bool		bIsNewChatWindow = false;

	if (pChatItem == NULL)
	{
		if (GetItemCount() >= 50)
		{
			AddDebugLogLine(RGB_LOG_WARNING_TXT _T("Instant Messaging: Messages limit reached"));
			return;
		}

		if (g_App.m_pPrefs->GetAcceptMessagesFrom() == 4) //no messages
			return;

		if ((g_App.m_pPrefs->GetAcceptMessagesFrom() == 2) && !pSender->IsFriend()) //only friends
			return;

		if ((g_App.m_pPrefs->GetAcceptMessagesFrom() == 3) && !pSender->IsFriend()) //log non friends
		{
			AddLogLine(false, GetResString(IDS_IM_MSGFROMCHAT) + _T(" %s: %s"), pSender->GetUserName(), strIncomingMessage);
			pSender->SetChatState(MS_NONE);
			return;
		}

		pChatItem = StartSession(pSender);
		if (pChatItem == NULL)
			return;
		bIsNewChatWindow = true;
	}
	COleDateTime	timelog(COleDateTime::GetCurrentTime());

	strMessage.Format(_T("%s (%s): "), pSender->GetUserName(), timelog.Format(_T("%c")));
	pChatItem->m_pLog->AppendText(strMessage, RGB(50, 200, 250));
	pChatItem->m_pLog->AppendText(strIncomingMessage + _T('\n'));

	if (g_App.m_pPrefs->GetAwayState())
	{
		if ((::GetTickCount() - pChatItem->m_pClient->GetAwayMessageResendCount()) > 3000)
		{ //send again only if 3 secs from last away message
			SendAwayMessage(pChatItem);
			pChatItem->m_pClient->SetAwayMessageResendCount(::GetTickCount());
		}
	}

	if ((iCurPos = GetTabByClient(pSender)) != GetCurSel())
		SetItemState(iCurPos, TCIS_HIGHLIGHTED, TCIS_HIGHLIGHTED);
	if (!g_App.m_pPrefs->GetAwayState())
	{
		BOOL	bVisible = ::IsWindowVisible(::GetParent(m_hWnd));

	//	Show statusbar indicator if Messages window isn't active or our application isn't topmost one
		if (!bVisible || (g_App.m_pMDlg->m_hWnd != ::GetForegroundWindow()))
		{
			pChatItem->m_bNotify = true;
		//	Send Notification is required
			if ( ( g_App.m_pPrefs->GetUseChatNotifier() &&
				(bIsNewChatWindow || g_App.m_pPrefs->GetNotifierPopsEveryChatMsg()) ) )
			{
				strMessage.Format(_T("%s %s:'%s'\n"), GetResString(IDS_TBN_NEWCHATMSG), pSender->GetUserName(), strIncomingMessage);
				g_App.m_pMDlg->SendMail(strMessage, true, g_App.m_pPrefs->IsSMTPInfoEnabled());
				g_App.m_pMDlg->ShowNotifier(strMessage, TBN_CHAT, false, true);
			}
		}
	}
}