void CPrivateChatFrame::OnProfileReceived()
{
	m_sNick = m_pSession->m_sUserNick;

	AddTimestamp();

	m_pContent.Add( retText, LoadString( IDS_CHAT_PROFILE_ACCEPTED ), NULL, retfColor )->m_cColor = Colors.m_crChatNull;
	m_pContent.Add( retLink, m_sNick, _T("command:ID_CHAT_BROWSE") );
	m_pContent.Add( retNewline, NEWLINE_FORMAT );
	m_wndView.InvalidateIfModified();

	CString strCaption;
	LoadString( strCaption, IDR_CHATFRAME );
	if ( Settings.General.LanguageRTL ) strCaption = _T("\x200F") + strCaption + _T("\x202E");
	strCaption += _T(" : ");
	if ( Settings.General.LanguageRTL ) strCaption += _T("\x202B");
	strCaption += m_sNick;
	CString strAddress;
	strAddress.Format( _T(" (%s:%lu)"),
		(LPCTSTR)CString( inet_ntoa( m_pSession->m_pHost.sin_addr ) ),
		ntohs( m_pSession->m_pHost.sin_port ) );
	if ( Settings.General.LanguageRTL ) strCaption += _T("\x200F");
	strCaption += strAddress;
	if ( ! m_pSession->m_sUserAgent.IsEmpty() )
	{
		if ( Settings.General.LanguageRTL ) strCaption += _T("\x200F");
		strCaption = strCaption + _T(" - ") + m_pSession->m_sUserAgent;
	}

	SetWindowText( strCaption );
	GetParent()->PostMessage( WM_TIMER, 2 );

	SetAlert();
}
Exemple #2
0
void CBrowseHostWnd::Serialize(CArchive& ar, int nVersion /* BROWSER_SER_VERSION */)
{
	if ( ar.IsStoring() )
	{
		ar << nVersion;

		ar << m_bOnFiles;
	}
	else
	{
		ar >> nVersion;
		if ( nVersion < 1 || nVersion > BROWSER_SER_VERSION ) AfxThrowUserException();

		ar >> m_bOnFiles;
	}

	CBaseMatchWnd::Serialize( ar );

	m_pBrowser->Serialize( ar, nVersion );
	m_wndProfile.Serialize( ar, nVersion  );
	m_wndFrame.Serialize( ar, nVersion );

	if ( ar.IsLoading() )
	{
		m_wndProfile.Update( m_pBrowser );

		PostMessage( WM_TIMER, 1 );
		SendMessage( WM_TIMER, 2 );
		SetAlert( FALSE );
	}
}
Exemple #3
0
LRESULT CChatWnd::OnChatMessage(WPARAM /*wParam*/, LPARAM lParam)
{
    CAutoPtr< CChatMessage > pMsg( (CChatMessage*)lParam );

    if ( pMsg->m_hBitmap )
    {
        CChatWnd::AddBitmap( pMsg->m_hBitmap );
    }

    switch ( pMsg->m_bType )
    {
    case cmtProfile:
        Open();
        SetAlert();
        CChatWnd::AddLogin( pMsg->m_sFrom );
        break;

    case cmtError:
        SetAlert();
    case cmtStatus:
    case cmtInfo:
        CChatWnd::OnStatusMessage( (int)pMsg->m_bType - (int)cmtStatus, pMsg->m_sMessage );
        break;

    case cmtMessage:
        CChatWnd::OnMessage( false, GetChatID(), false, pMsg->m_sFrom, MyProfile.GetNick(), pMsg->m_sMessage );
        break;

    case cmtAction:
        CChatWnd::OnMessage( false, GetChatID(), false, pMsg->m_sFrom, MyProfile.GetNick(), pMsg->m_sMessage );
        break;

    case cmtCaption:
        m_sCaption = _T(" : ") + pMsg->m_sMessage;
        break;

    default:
        ;
    }

    SetWindowText( GetCaption() + m_sCaption );

    return 0;
}
Exemple #4
0
void CChildWnd::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
	if ( theApp.m_bClosing || GetManager()->m_bIgnoreActivate ) return;

	if ( bActivate && m_bAlert ) SetAlert( FALSE );

	CMDIChildWnd::OnMDIActivate( bActivate, pActivateWnd, pDeactivateWnd );

	if ( bActivate && m_bGroupMode )
		GetManager()->ActivateGrouped( this );
}
int CChatWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if ( CChildWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;

	ASSERT_VALID( m_pFrame );

	m_pFrame->SetParent( this );

	LoadState( _T("CChatWnd"), FALSE );

	CRect rc;
	GetClientRect( &rc );
	m_pFrame->MoveWindow( &rc, TRUE );

	SetAlert();

	return 0;
}
Exemple #6
0
void CSearchWnd::Serialize(CArchive& ar)
{
    CQuickLock pLock( m_pMatches->m_pSection );

    int nVersion = 1;

    if ( ar.IsStoring() )
    {
        ar << nVersion;

        ar.WriteCount( size() );

        for ( iterator pManaged = begin() ; pManaged != end() ; ++pManaged )
        {
            (*pManaged)->Serialize( ar );
        }
    }
    else  // Loading
    {
        ar >> nVersion;
        if ( nVersion != 1 ) AfxThrowUserException();

        for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
        {
            CSearchPtr pManaged( new CManagedSearch() );
            pManaged->Serialize( ar );
            m_oSearches.push_back( pManaged );
        }
    }

    CBaseMatchWnd::Serialize( ar );

    if ( ar.IsLoading() )
    {
        if ( ! empty() )
            m_wndPanel.ShowSearch( m_oSearches.back() );

        PostMessage( WM_TIMER, 1 );
        SendMessage( WM_TIMER, 2 );
        SetAlert( FALSE );
    }
}
void CPrivateChatFrame::OnRemoteMessage(BOOL bAction, LPCTSTR pszText)
{
	// Check message spam filter (if enabled)
	if ( MessageFilter.IsFiltered( pszText ) )
		return;

	DWORD nIdle = (DWORD)time( NULL ) - theApp.m_nLastInput;

	if ( nIdle > Settings.Community.AwayMessageIdleTime )
	{
		CString strTime;
		if ( nIdle > 86400 )
			strTime.Format( _T("%u:%.2u:%.2u:%.2u"), nIdle / 86400, ( nIdle / 3600 ) % 24, ( nIdle / 60 ) % 60, nIdle % 60 );
		else
			strTime.Format( _T("%u:%.2u:%.2u"), nIdle / 3600, ( nIdle / 60 ) % 60, nIdle % 60 );

		CString strMessage;
		strMessage.Format( LoadString( IDS_CHAT_PRIVATE_AWAY ), _T(""), strTime );
		m_pSession->SendPrivateMessage( true, strMessage );
	}

	// Adult filter (if enabled)
	if ( AdultFilter.IsChatFiltered( pszText ) )
		AdultFilter.Censor( (TCHAR*)pszText );

	// Notify chat plugins about new remote message
	CString strChatID;
	strChatID.Format( _T("%s:%hu"),
		(LPCTSTR)CString( inet_ntoa( m_pSession->m_pHost.sin_addr ) ),
		ntohs( m_pSession->m_pHost.sin_port ) );
	Plugins.OnChatMessage( strChatID, FALSE, m_sNick, MyProfile.GetNick(), pszText );

	AddText( FALSE, bAction, m_sNick, pszText );
	SetAlert();
	PostMessage( WM_TIMER, 4 );
}
Exemple #8
0
void CChatWnd::OnMessage(bool bAction, const CString& sChatID, bool bOutgoing, const CString& sFrom, const CString& sTo, const CString& sText)
{
    // Check incoming message spam filter (if enabled)
    if ( ! bOutgoing && MessageFilter.IsFiltered( sText ) )
        return;

    // Notify chat plugins about new message
    Plugins.OnChatMessage( sChatID, bOutgoing, sFrom, sTo, sText );

    // Adult filter (if enabled)
    CString sCensoredText( sText );
    if ( Settings.Community.ChatCensor )
    {
        AdultFilter.Censor( sCensoredText );
    }
    AddText( bAction, bOutgoing, sFrom, sCensoredText );

    SetAlert();

    if ( CMainWnd* pWnd = theApp.CShareazaApp::SafeMainWnd() )
    {
        if ( GetForegroundWindow() != pWnd )
        {
            // pWnd->ShowTrayPopup( sText, sFrom, NIIF_NONE, 30 );

            FLASHWINFO pFWX =
            {
                sizeof( pFWX ),
                pWnd->GetSafeHwnd(),
                FLASHW_ALL | FLASHW_TIMERNOFG,
                1000
            };
            ::FlashWindowEx( &pFWX );
        }
    }
}
void CBaseMatchWnd::OnTimer(UINT nIDEvent) 
{
	if ( m_wndFilter.m_hWnd == NULL ) return;
	
	DWORD nNow = GetTickCount();
	
	if ( nIDEvent == 1 )
	{
		if ( GetFocus() != &m_wndFilter )
		{
			CString strFilter;
			m_wndFilter.GetWindowText( strFilter );
			
			if ( strFilter != m_pMatches->m_sFilter )
			{
				m_wndFilter.SetWindowText( m_pMatches->m_sFilter );
			}
		}
		
		BOOL bActive = ( GetMDIFrame()->MDIGetActive() == this );
		
		if ( bActive )
		{
			if ( HWND hFore = ::GetForegroundWindow() )
			{
				DWORD nProcessID;
				GetWindowThreadProcessId( hFore, &nProcessID );
				bActive &= ( nProcessID == GetCurrentProcessId() );
			}
		}
		
		if ( m_bBMWActive != bActive )
		{
			m_bBMWActive = bActive;
			
			if ( ! m_bBMWActive )
			{
				m_pMatches->ClearNew();
				m_wndList.Invalidate();
			}
		}
		
		if ( m_pMatches->m_nFilteredFiles == 0 ) UpdateMessages( FALSE );
	}
	else if ( ( nIDEvent == 2 && m_bUpdate ) || nIDEvent == 7 )
	{
		CSingleLock pLock( &m_pMatches->m_pSection );
		
		if ( pLock.Lock( 50 ) )
		{
			m_bUpdate = FALSE;
			m_wndList.Update();
			UpdateMessages();
			
			if ( m_pMatches->m_nFilteredFiles != m_nCacheFiles )
			{
				m_nCacheFiles = m_pMatches->m_nFilteredFiles;
				SetAlert();
			}
		}
		else
		{
			m_bUpdate = TRUE;
			PostMessage( WM_TIMER, 2 );
		}
	}
}