Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

WndHitMonitor.cpp

Go to the documentation of this file.
00001 //
00002 // WndHitMonitor.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "QuerySearch.h"
00026 #include "QueryHit.h"
00027 #include "MatchObjects.h"
00028 #include "Network.h"
00029 #include "Packet.h"
00030 #include "Schema.h"
00031 #include "SchemaCache.h"
00032 #include "Skin.h"
00033 
00034 #include "WndHitMonitor.h"
00035 #include "WndSearch.h"
00036 #include "DlgHitColumns.h"
00037 #include "DlgNewSearch.h"
00038 
00039 #ifdef _DEBUG
00040 #define new DEBUG_NEW
00041 #undef THIS_FILE
00042 static char THIS_FILE[] = __FILE__;
00043 #endif
00044 
00045 IMPLEMENT_SERIAL(CHitMonitorWnd, CBaseMatchWnd, 0)
00046 
00047 BEGIN_MESSAGE_MAP(CHitMonitorWnd, CBaseMatchWnd)
00048         //{{AFX_MSG_MAP(CHitMonitorWnd)
00049         ON_WM_CREATE()
00050         ON_WM_DESTROY()
00051         ON_WM_CONTEXTMENU()
00052         ON_COMMAND(ID_HITMONITOR_CLEAR, OnHitMonitorClear)
00053         ON_UPDATE_COMMAND_UI(ID_HITMONITOR_PAUSE, OnUpdateHitMonitorPause)
00054         ON_COMMAND(ID_HITMONITOR_PAUSE, OnHitMonitorPause)
00055         //}}AFX_MSG_MAP
00056 END_MESSAGE_MAP()
00057 
00058 
00060 // CHitMonitorWnd construction
00061 
00062 CHitMonitorWnd::CHitMonitorWnd()
00063 {
00064         Create( IDR_HITMONITORFRAME );
00065 }
00066 
00067 CHitMonitorWnd::~CHitMonitorWnd()
00068 {
00069 }
00070 
00072 // CHitMonitorWnd message handlers
00073 
00074 int CHitMonitorWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
00075 {
00076         if ( CBaseMatchWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
00077 
00078         m_pMatches->m_sFilter = Settings.Search.MonitorFilter;
00079         m_pMatches->Filter();
00080 
00081         if ( CSchema* pSchema = SchemaCache.Get( Settings.Search.MonitorSchemaURI ) )
00082         {
00083                 CPtrList pColumns;
00084                 CSchemaColumnsDlg::LoadColumns( pSchema, &pColumns );
00085                 m_wndList.SelectSchema( pSchema, &pColumns );
00086         }
00087 
00088         LoadState( _T("CHitMonitorWnd"), TRUE );
00089 
00090         return 0;
00091 }
00092 
00093 void CHitMonitorWnd::OnDestroy()
00094 {
00095         Settings.Search.MonitorFilter = m_pMatches->m_sFilter;
00096 
00097         if ( m_wndList.m_pSchema )
00098         {
00099                 Settings.Search.MonitorSchemaURI = m_wndList.m_pSchema->m_sURI;
00100         }
00101         else
00102         {
00103                 Settings.Search.MonitorSchemaURI.Empty();
00104         }
00105 
00106         SaveState( _T("CHitMonitorWnd") );
00107 
00108         CBaseMatchWnd::OnDestroy();
00109 }
00110 
00111 void CHitMonitorWnd::OnContextMenu(CWnd* pWnd, CPoint point)
00112 {
00113         if ( m_bContextMenu )
00114         {
00115                 TrackPopupMenu( _T("CHitMonitorWnd"), point, ID_SEARCH_DOWNLOAD );
00116         }
00117         else
00118         {
00119                 CBaseMatchWnd::OnContextMenu( pWnd, point );
00120         }
00121 }
00122 
00123 void CHitMonitorWnd::OnUpdateHitMonitorPause(CCmdUI* pCmdUI)
00124 {
00125         pCmdUI->SetCheck( m_bPaused );
00126 }
00127 
00128 void CHitMonitorWnd::OnHitMonitorPause()
00129 {
00130         m_bPaused = ! m_bPaused;
00131 }
00132 
00133 void CHitMonitorWnd::OnHitMonitorClear()
00134 {
00135         m_wndList.DestructiveUpdate();
00136         m_pMatches->Clear();
00137         m_bUpdate = TRUE;
00138         PostMessage( WM_TIMER, 2 );
00139 }
00140 
00142 // CHitMonitorWnd event handlers
00143 
00144 void CHitMonitorWnd::OnSkinChange()
00145 {
00146         CBaseMatchWnd::OnSkinChange();
00147         Skin.Translate( _T("CMatchCtrl"), &m_wndList.m_wndHeader );
00148         Skin.CreateToolBar( _T("CHitMonitorWnd"), &m_wndToolBar );
00149 }
00150 
00151 BOOL CHitMonitorWnd::OnQueryHits(CQueryHit* pHits)
00152 {
00153         if ( m_bPaused || m_hWnd == NULL ) return FALSE;
00154 
00155         CSingleLock pLock( &m_pMatches->m_pSection );
00156 
00157         if ( pLock.Lock( 100 ) && ! m_bPaused )
00158         {
00159                 m_pMatches->AddHits( pHits );
00160                 m_bUpdate = TRUE;
00161                 return TRUE;
00162         }
00163 
00164         return FALSE;
00165 }

Generated on Thu Dec 15 10:39:52 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2