00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
00056 END_MESSAGE_MAP()
00057
00058
00060
00061
00062 CHitMonitorWnd::CHitMonitorWnd()
00063 {
00064 Create( IDR_HITMONITORFRAME );
00065 }
00066
00067 CHitMonitorWnd::~CHitMonitorWnd()
00068 {
00069 }
00070
00072
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
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 }