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 "Transfers.h"
00026 #include "Downloads.h"
00027 #include "Download.h"
00028 #include "DownloadSource.h"
00029 #include "DownloadTransfer.h"
00030 #include "DownloadGroups.h"
00031
00032 #include "Library.h"
00033 #include "LibraryMaps.h"
00034 #include "SharedFile.h"
00035 #include "FileExecutor.h"
00036 #include "ShareazaURL.h"
00037 #include "SHA.h"
00038 #include "ChatWindows.h"
00039
00040 #include "WindowManager.h"
00041 #include "WndDownloads.h"
00042 #include "WndUploads.h"
00043 #include "WndBrowseHost.h"
00044 #include "DlgDownload.h"
00045 #include "DlgDownloadReviews.h"
00046 #include "DlgDownloadEdit.h"
00047 #include "DlgSettingsManager.h"
00048 #include "DlgTorrentTracker.h"
00049 #include "DlgDeleteFile.h"
00050 #include "DlgFilePropertiesSheet.h"
00051 #include "DlgURLCopy.h"
00052 #include "DlgHelp.h"
00053 #include "Skin.h"
00054 #include "Network.h"
00055
00056 #ifdef _DEBUG
00057 #define new DEBUG_NEW
00058 #undef THIS_FILE
00059 static char THIS_FILE[] = __FILE__;
00060 #endif
00061
00062 IMPLEMENT_SERIAL(CDownloadsWnd, CPanelWnd, 0)
00063
00064 BEGIN_MESSAGE_MAP(CDownloadsWnd, CPanelWnd)
00065 ON_WM_CREATE()
00066 ON_WM_DESTROY()
00067 ON_WM_SIZE()
00068 ON_WM_TIMER()
00069 ON_WM_CONTEXTMENU()
00070 ON_WM_MEASUREITEM()
00071 ON_WM_DRAWITEM()
00072 ON_WM_MDIACTIVATE()
00073 ON_WM_MOUSEMOVE()
00074 ON_WM_LBUTTONUP()
00075 ON_WM_RBUTTONDOWN()
00076 ON_WM_KEYDOWN()
00077 ON_WM_KEYUP()
00078 ON_WM_SETCURSOR()
00079 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_RESUME, OnUpdateDownloadsResume)
00080 ON_COMMAND(ID_DOWNLOADS_RESUME, OnDownloadsResume)
00081 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_PAUSE, OnUpdateDownloadsPause)
00082 ON_COMMAND(ID_DOWNLOADS_PAUSE, OnDownloadsPause)
00083 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_CLEAR, OnUpdateDownloadsClear)
00084 ON_COMMAND(ID_DOWNLOADS_CLEAR, OnDownloadsClear)
00085 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_LAUNCH, OnUpdateDownloadsLaunch)
00086 ON_COMMAND(ID_DOWNLOADS_LAUNCH, OnDownloadsLaunch)
00087 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_VIEW_REVIEWS, OnUpdateDownloadsViewReviews)
00088 ON_COMMAND(ID_DOWNLOADS_VIEW_REVIEWS, OnDownloadsViewReviews)
00089 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_SOURCES, OnUpdateDownloadsSources)
00090 ON_COMMAND(ID_DOWNLOADS_SOURCES, OnDownloadsSources)
00091 ON_COMMAND(ID_DOWNLOADS_CLEAR_COMPLETED, OnDownloadsClearCompleted)
00092 ON_COMMAND(ID_DOWNLOADS_CLEAR_PAUSED, OnDownloadsClearPaused)
00093 ON_UPDATE_COMMAND_UI(ID_TRANSFERS_DISCONNECT, OnUpdateTransfersDisconnect)
00094 ON_COMMAND(ID_TRANSFERS_DISCONNECT, OnTransfersDisconnect)
00095 ON_UPDATE_COMMAND_UI(ID_TRANSFERS_FORGET, OnUpdateTransfersForget)
00096 ON_COMMAND(ID_TRANSFERS_FORGET, OnTransfersForget)
00097 ON_UPDATE_COMMAND_UI(ID_TRANSFERS_CHAT, OnUpdateTransfersChat)
00098 ON_COMMAND(ID_TRANSFERS_CHAT, OnTransfersChat)
00099 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_URL, OnUpdateDownloadsUrl)
00100 ON_COMMAND(ID_DOWNLOADS_URL, OnDownloadsUrl)
00101 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_ENQUEUE, OnUpdateDownloadsEnqueue)
00102 ON_COMMAND(ID_DOWNLOADS_ENQUEUE, OnDownloadsEnqueue)
00103 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_AUTO_CLEAR, OnUpdateDownloadsAutoClear)
00104 ON_COMMAND(ID_DOWNLOADS_AUTO_CLEAR, OnDownloadsAutoClear)
00105 ON_UPDATE_COMMAND_UI(ID_TRANSFERS_CONNECT, OnUpdateTransfersConnect)
00106 ON_COMMAND(ID_TRANSFERS_CONNECT, OnTransfersConnect)
00107 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_SHOW_SOURCES, OnUpdateDownloadsShowSources)
00108 ON_COMMAND(ID_DOWNLOADS_SHOW_SOURCES, OnDownloadsShowSources)
00109 ON_UPDATE_COMMAND_UI(ID_BROWSE_LAUNCH, OnUpdateBrowseLaunch)
00110 ON_COMMAND(ID_BROWSE_LAUNCH, OnBrowseLaunch)
00111 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_BOOST, OnUpdateDownloadsBoost)
00112 ON_COMMAND(ID_DOWNLOADS_BOOST, OnDownloadsBoost)
00113 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_LAUNCH_COPY, OnUpdateDownloadsLaunchCopy)
00114 ON_COMMAND(ID_DOWNLOADS_LAUNCH_COPY, OnDownloadsLaunchCopy)
00115 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_MONITOR, OnUpdateDownloadsMonitor)
00116 ON_COMMAND(ID_DOWNLOADS_MONITOR, OnDownloadsMonitor)
00117 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILE_DELETE, OnUpdateDownloadsFileDelete)
00118 ON_COMMAND(ID_DOWNLOADS_FILE_DELETE, OnDownloadsFileDelete)
00119 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_RATE, OnUpdateDownloadsRate)
00120 ON_COMMAND(ID_DOWNLOADS_RATE, OnDownloadsRate)
00121 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_MOVE_UP, OnUpdateDownloadsMoveUp)
00122 ON_COMMAND(ID_DOWNLOADS_MOVE_UP, OnDownloadsMoveUp)
00123 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_MOVE_DOWN, OnUpdateDownloadsMoveDown)
00124 ON_COMMAND(ID_DOWNLOADS_MOVE_DOWN, OnDownloadsMoveDown)
00125 ON_COMMAND(ID_DOWNLOADS_SETTINGS, OnDownloadsSettings)
00126 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILTER_ALL, OnUpdateDownloadsFilterAll)
00127 ON_COMMAND(ID_DOWNLOADS_FILTER_ALL, OnDownloadsFilterAll)
00128 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILTER_ACTIVE, OnUpdateDownloadsFilterActive)
00129 ON_COMMAND(ID_DOWNLOADS_FILTER_ACTIVE, OnDownloadsFilterActive)
00130 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILTER_QUEUED, OnUpdateDownloadsFilterQueued)
00131 ON_COMMAND(ID_DOWNLOADS_FILTER_QUEUED, OnDownloadsFilterQueued)
00132 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILTER_SOURCES, OnUpdateDownloadsFilterSources)
00133 ON_COMMAND(ID_DOWNLOADS_FILTER_SOURCES, OnDownloadsFilterSources)
00134 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_FILTER_PAUSED, OnUpdateDownloadsFilterPaused)
00135 ON_COMMAND(ID_DOWNLOADS_FILTER_PAUSED, OnDownloadsFilterPaused)
00136 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_LAUNCH_COMPLETE, OnUpdateDownloadsLaunchComplete)
00137 ON_COMMAND(ID_DOWNLOADS_LAUNCH_COMPLETE, OnDownloadsLaunchComplete)
00138 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_SHARE, OnUpdateDownloadsShare)
00139 ON_COMMAND(ID_DOWNLOADS_SHARE, OnDownloadsShare)
00140 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_COPY, OnUpdateDownloadsCopy)
00141 ON_COMMAND(ID_DOWNLOADS_COPY, OnDownloadsCopy)
00142 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_TORRENT_INFO, OnUpdateDownloadsTorrentInfo)
00143 ON_COMMAND(ID_DOWNLOADS_TORRENT_INFO, OnDownloadsTorrentInfo)
00144 ON_UPDATE_COMMAND_UI(ID_DOWNLOAD_GROUP_SHOW, OnUpdateDownloadGroupShow)
00145 ON_COMMAND(ID_DOWNLOAD_GROUP_SHOW, OnDownloadGroupShow)
00146 ON_COMMAND(ID_DOWNLOADS_HELP, OnDownloadsHelp)
00147 ON_COMMAND(ID_DOWNLOADS_FILTER_MENU, OnDownloadsFilterMenu)
00148 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_CLEAR_INCOMPLETE, OnUpdateDownloadsClearIncomplete)
00149 ON_COMMAND(ID_DOWNLOADS_CLEAR_INCOMPLETE, OnDownloadsClearIncomplete)
00150 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_CLEAR_COMPLETE, OnUpdateDownloadsClearComplete)
00151 ON_COMMAND(ID_DOWNLOADS_CLEAR_COMPLETE, OnDownloadsClearComplete)
00152 ON_UPDATE_COMMAND_UI(ID_DOWNLOADS_EDIT, OnUpdateDownloadsEdit)
00153 ON_COMMAND(ID_DOWNLOADS_EDIT, OnDownloadsEdit)
00154 END_MESSAGE_MAP()
00155
00156
00158
00159
00160 CDownloadsWnd::CDownloadsWnd() : CPanelWnd( TRUE, TRUE )
00161 {
00162 Create( IDR_DOWNLOADSFRAME );
00163 }
00164
00165 CDownloadsWnd::~CDownloadsWnd()
00166 {
00167 }
00168
00170
00171
00172 int CDownloadsWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
00173 {
00174 if ( CPanelWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
00175
00176 if ( ! m_wndTabBar.Create( this, WS_CHILD|CBRS_TOP, AFX_IDW_TOOLBAR+1 ) ) return -1;
00177 m_wndTabBar.SetBarStyle( m_wndTabBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_BORDER_BOTTOM );
00178 if ( ! m_wndToolBar.Create( this, WS_CHILD|WS_VISIBLE|CBRS_NOALIGN, AFX_IDW_TOOLBAR ) ) return -1;
00179 m_wndToolBar.SetBarStyle( m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_BORDER_TOP );
00180 m_wndToolBar.SetSyncObject( &Transfers.m_pSection );
00181
00182 m_wndDownloads.Create( this, IDC_DOWNLOADS );
00183
00184 LoadState( NULL, TRUE );
00185
00186 SetTimer( 2, 2000, NULL );
00187 PostMessage( WM_TIMER, 2 );
00188
00189 SetTimer( 4, 10000, NULL );
00190 PostMessage( WM_TIMER, 4 );
00191
00192 m_pDragList = NULL;
00193 m_pDragImage = NULL;
00194 m_hCursMove = AfxGetApp()->LoadCursor( IDC_MOVE );
00195 m_hCursCopy = AfxGetApp()->LoadCursor( IDC_COPY );
00196 m_tSel = 0;
00197
00198 m_nMoreSourcesLimiter = 8;
00199 m_tMoreSourcesTimer = 0;
00200 m_tLastUpdate = 0;
00201
00202 return 0;
00203 }
00204
00205 void CDownloadsWnd::OnDestroy()
00206 {
00207 CancelDrag();
00208 KillTimer( 4 );
00209 KillTimer( 2 );
00210 SaveState();
00211 CPanelWnd::OnDestroy();
00212 }
00213
00214 void CDownloadsWnd::OnSkinChange()
00215 {
00216 CPanelWnd::OnSkinChange();
00217 Skin.Translate( _T("CDownloadCtrl"), &m_wndDownloads.m_wndHeader);
00218 Skin.CreateToolBar( _T("CDownloadsWnd"), &m_wndToolBar );
00219 }
00220
00221 void CDownloadsWnd::Update()
00222 {
00223 int nCookie = 0;
00224 DWORD tNow = GetTickCount();
00225
00226 m_tLastUpdate = tNow;
00227
00228 if ( Settings.General.GUIMode != GUI_BASIC && Settings.Downloads.ShowGroups )
00229 {
00230 nCookie = (int)tNow;
00231 m_wndTabBar.Update( nCookie );
00232 }
00233
00234 m_wndDownloads.Update( nCookie );
00235 }
00236
00237 BOOL CDownloadsWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
00238 {
00239 if ( m_wndToolBar.m_hWnd )
00240 {
00241 if ( m_wndToolBar.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) ) return TRUE;
00242 }
00243
00244 if ( m_wndTabBar.m_hWnd )
00245 {
00246 if ( m_wndTabBar.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) ) return TRUE;
00247 }
00248
00249 return CPanelWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
00250 }
00251
00252 void CDownloadsWnd::OnSize(UINT nType, int cx, int cy)
00253 {
00254 CPanelWnd::OnSize( nType, cx, cy );
00255
00256 CRect rc( 0, 0, cx, cy - 28 );
00257
00258 BOOL bTabs = ( Settings.General.GUIMode != GUI_BASIC ) && Settings.Downloads.ShowGroups;
00259
00260 if ( bTabs )
00261 rc.top += 24;
00262 else
00263 m_wndTabBar.ShowWindow( SW_HIDE );
00264
00265 HDWP hPos = BeginDeferWindowPos( bTabs ? 3 : 2 );
00266 DeferWindowPos( hPos, m_wndDownloads, NULL,
00267 rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER|SWP_SHOWWINDOW );
00268 if ( bTabs ) DeferWindowPos( hPos, m_wndTabBar, NULL,
00269 rc.left, 0, rc.Width(), 24, SWP_NOZORDER|SWP_SHOWWINDOW );
00270 DeferWindowPos( hPos, m_wndToolBar, NULL,
00271 rc.left, rc.bottom, rc.Width(), 28, SWP_NOZORDER );
00272 EndDeferWindowPos( hPos );
00273 }
00274
00275 void CDownloadsWnd::OnTimer(UINT nIDEvent)
00276 {
00277
00278 if ( nIDEvent == 5 ) m_tSel = 0;
00279
00280
00281 if ( nIDEvent == 4 )
00282 {
00283 DWORD tNow = GetTickCount();
00284
00285 if ( ( tNow - m_tMoreSourcesTimer ) > 8*60*1000 )
00286 {
00287 if ( m_nMoreSourcesLimiter < 15 ) m_nMoreSourcesLimiter ++;
00288
00289 m_tMoreSourcesTimer = tNow;
00290 }
00291
00292
00293 if ( Settings.Downloads.AutoClear || Settings.BitTorrent.AutoClear )
00294 {
00295
00296 CSingleLock pLock( &Transfers.m_pSection );
00297 if ( ! pLock.Lock( 10 ) ) return;
00298
00299
00300
00301
00302 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00303 {
00304 CDownload* pDownload = Downloads.GetNext( pos );
00305
00306 if ( pDownload->IsCompleted() &&
00307 pDownload->IsPreviewVisible() == FALSE &&
00308 tNow - pDownload->m_tCompleted > Settings.Downloads.ClearDelay )
00309 {
00310
00311 if ( pDownload->m_pTorrent.IsAvailable() == TRUE )
00312 {
00313
00314 if ( Settings.BitTorrent.AutoClear )
00315 {
00316
00317 if ( ( ! pDownload->IsSeeding() ) && ( Settings.BitTorrent.ClearRatio < pDownload->GetRatio() * 100.0f) )
00318 {
00319 pDownload->Remove();
00320 }
00321 }
00322 }
00323 else
00324 {
00325
00326 if ( Settings.Downloads.AutoClear )
00327 {
00328 pDownload->Remove();
00329 }
00330 }
00331 }
00332 }
00333 }
00334 }
00335
00336
00337 if ( ( nIDEvent == 2 ) && ( m_pDragList == NULL ) )
00338 {
00339
00340 if ( ( IsWindowVisible() && IsActive( FALSE ) ) || ( ( GetTickCount() - m_tLastUpdate ) > 10*1000 ) )
00341 {
00342
00343 Update();
00344 }
00345 }
00346 }
00347
00348 void CDownloadsWnd::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
00349 {
00350 CPanelWnd::OnMDIActivate( bActivate, pActivateWnd, pDeactivateWnd );
00351
00352 if ( bActivate )
00353 {
00354 Update();
00355 m_wndDownloads.SetFocus();
00356 }
00357 }
00358
00359 void CDownloadsWnd::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
00360 {
00361 AfxGetMainWnd()->SendMessage( WM_MEASUREITEM, nIDCtl, (LPARAM)lpMeasureItemStruct );
00362 }
00363
00364 void CDownloadsWnd::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
00365 {
00366 AfxGetMainWnd()->SendMessage( WM_DRAWITEM, nIDCtl, (LPARAM)lpDrawItemStruct );
00367 }
00368
00369 void CDownloadsWnd::OnContextMenu(CWnd* pWnd, CPoint point)
00370 {
00371 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00372 CDownloadSource* pSource;
00373 CDownload* pDownload;
00374
00375 CPoint ptLocal( point );
00376 m_wndDownloads.ScreenToClient( &ptLocal );
00377 m_tSel = 0;
00378
00379 if ( m_wndDownloads.HitTest( ptLocal, &pDownload, &pSource, NULL, NULL ) )
00380 {
00381 if ( pSource != NULL )
00382 {
00383 pLock.Unlock();
00384 TrackPopupMenu( _T("CDownloadsWnd.Source"), point, ID_TRANSFERS_CONNECT );
00385 return;
00386 }
00387 else if ( pDownload->IsSeeding() )
00388 {
00389 pLock.Unlock();
00390 TrackPopupMenu( _T("CDownloadsWnd.Seeding"), point, ID_DOWNLOADS_LAUNCH );
00391 return;
00392 }
00393 else if ( pDownload->IsCompleted() )
00394 {
00395 pLock.Unlock();
00396 TrackPopupMenu( _T("CDownloadsWnd.Completed"), point, ID_DOWNLOADS_LAUNCH );
00397 return;
00398 }
00399 }
00400
00401 if ( pDownload != NULL )
00402 TrackPopupMenu( _T("CDownloadsWnd.Download"), point,
00403 Settings.General.GUIMode == GUI_BASIC ? ID_DOWNLOADS_LAUNCH_COPY : ID_DOWNLOADS_LAUNCH );
00404 else
00405 TrackPopupMenu( _T("CDownloadsWnd.Nothing"), point, ID_DOWNLOADS_HELP );
00406
00407 pLock.Unlock();
00408 }
00409
00410 BOOL CDownloadsWnd::PreTranslateMessage(MSG* pMsg)
00411 {
00412 if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB )
00413 {
00414 GetManager()->Open( RUNTIME_CLASS(CUploadsWnd) );
00415 return TRUE;
00416 }
00417
00418 return CPanelWnd::PreTranslateMessage( pMsg );
00419 }
00420
00421 BOOL CDownloadsWnd::Select(CDownload* pSelect)
00422 {
00423 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00424 BOOL bFound = FALSE;
00425
00426 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00427 {
00428 CDownload* pDownload = Downloads.GetNext( pos );
00429
00430 if ( pDownload == pSelect )
00431 {
00432 pDownload->m_bSelected = TRUE;
00433 bFound = TRUE;
00434 }
00435 else
00436 {
00437 pDownload->m_bSelected = FALSE;
00438 }
00439
00440 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; pSource = pSource->m_pNext )
00441 {
00442 pSource->m_bSelected = FALSE;
00443 }
00444 }
00445
00446 Invalidate();
00447 m_tSel = 0;
00448
00449 return bFound;
00450 }
00451
00452 void CDownloadsWnd::Prepare()
00453 {
00454 DWORD tNow = GetTickCount();
00455 if ( tNow - m_tSel < 250 ) return;
00456 m_tSel = tNow;
00457
00458 m_bSelAny = m_bSelDownload = m_bSelSource = m_bSelTrying = m_bSelPaused = FALSE;
00459 m_bSelNotPausedOrMoving = m_bSelNoPreview = m_bSelNotCompleteAndNoPreview = FALSE;
00460 m_bSelCompletedAndNoPreview = m_bSelStartedAndNotMoving = m_bSelCompleted = FALSE;
00461 m_bSelNotMoving = m_bSelBoostable = m_bSelSHA1orED2K = FALSE;
00462 m_bSelTorrent = m_bSelIdleSource = m_bSelActiveSource = FALSE;
00463 m_bSelHttpSource = m_bSelDonkeySource = m_bSelShareState = FALSE;
00464 m_bSelShareConsistent = TRUE;
00465 m_bSelMoreSourcesOK = FALSE;
00466 m_bSelSourceAcceptConnections = m_bSelSourceExtended = m_bSelHasReviews = FALSE;
00467
00468 m_bConnectOkay = FALSE;
00469
00470 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00471 BOOL bFirstShare = TRUE;
00472
00473 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00474 {
00475 CDownload* pDownload = Downloads.GetNext( pos );
00476
00477 if ( pDownload->m_bSelected )
00478 {
00479 m_bSelAny = TRUE;
00480 m_bSelDownload = TRUE;
00481 if ( pDownload->IsCompleted() )
00482 m_bSelCompleted = TRUE;
00483 if ( ! pDownload->IsMoving() )
00484 m_bSelNotMoving = TRUE;
00485 if ( ! pDownload->IsBoosted() )
00486 m_bSelBoostable = TRUE;
00487 if ( pDownload->m_bSHA1 || pDownload->m_bED2K )
00488 m_bSelSHA1orED2K = TRUE;
00489 if ( pDownload->m_pTorrent.IsAvailable() )
00490 m_bSelTorrent = TRUE;
00491 if ( pDownload->IsTrying() )
00492 m_bSelTrying = TRUE;
00493 if ( pDownload->IsPaused() )
00494 m_bSelPaused = TRUE;
00495 else if ( ! pDownload->IsMoving() )
00496 {
00497 m_bSelNotPausedOrMoving = TRUE;
00498 if ( pDownload->IsTrying() && pDownload->FindSourcesAllowed( tNow ) )
00499 m_bSelMoreSourcesOK = TRUE;
00500 }
00501
00502 if ( ! pDownload->IsPreviewVisible() )
00503 {
00504 m_bSelNoPreview = TRUE;
00505 if ( pDownload->IsCompleted() )
00506 m_bSelCompletedAndNoPreview = TRUE;
00507 else
00508 m_bSelNotCompleteAndNoPreview = TRUE;
00509 }
00510 if ( pDownload->IsStarted() && ! pDownload->IsMoving() )
00511 m_bSelStartedAndNotMoving = TRUE;
00512 if ( bFirstShare )
00513 {
00514 m_bSelShareState = pDownload->IsShared();
00515 bFirstShare = FALSE;
00516 }
00517 else if ( m_bSelShareState != pDownload->IsShared() )
00518 {
00519 m_bSelShareState = FALSE;
00520 m_bSelShareConsistent = FALSE;
00521 }
00522 if ( pDownload->GetReviewCount() > 0 )
00523 m_bSelHasReviews = TRUE;
00524 }
00525
00526 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource ; pSource = pSource->m_pNext )
00527 {
00528 if ( pSource->m_bSelected )
00529 {
00530 m_bSelAny = TRUE;
00531 m_bSelSource = TRUE;
00532 if ( pSource->m_pTransfer == NULL )
00533 m_bSelIdleSource = TRUE;
00534 else
00535 m_bSelActiveSource = TRUE;
00536 if ( pSource->m_nProtocol == PROTOCOL_HTTP ) m_bSelHttpSource = TRUE;
00537 if ( pSource->m_nProtocol == PROTOCOL_ED2K ) m_bSelDonkeySource = TRUE;
00538 if ( ! pSource->m_bPushOnly ) m_bSelSourceAcceptConnections = TRUE;
00539 m_bSelSourceExtended = pSource->m_bClientExtended;
00540 }
00541 }
00542 }
00543
00544 if ( ( ! Settings.Connection.RequireForTransfers ) || ( Network.IsConnected() ) )
00545 m_bConnectOkay = TRUE;
00546 }
00547
00549
00550
00551 void CDownloadsWnd::OnUpdateDownloadsResume(CCmdUI* pCmdUI)
00552 {
00553 Prepare();
00554 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00555 pcCmdUI->Show( m_bSelPaused || ( m_bSelDownload && ! m_bSelTrying ) );
00556 pCmdUI->Enable( m_bSelPaused || ( m_bSelDownload && ! m_bSelTrying ) );
00557 }
00558
00559 void CDownloadsWnd::OnDownloadsResume()
00560 {
00561 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00562
00563 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00564 {
00565 CDownload* pDownload = Downloads.GetNext( pos );
00566
00567 if ( pDownload->m_bSelected )
00568 {
00569 pDownload->Resume();
00570 }
00571 }
00572
00573 Update();
00574 }
00575
00576 void CDownloadsWnd::OnUpdateDownloadsPause(CCmdUI* pCmdUI)
00577 {
00578 Prepare();
00579 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00580 pcCmdUI->Show( m_bSelNotPausedOrMoving || ! m_bSelDownload );
00581 pCmdUI->Enable( m_bSelNotPausedOrMoving );
00582 }
00583
00584 void CDownloadsWnd::OnDownloadsPause()
00585 {
00586 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00587
00588 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00589 {
00590 CDownload* pDownload = Downloads.GetNext( pos );
00591
00592 if ( pDownload->m_bSelected )
00593 {
00594 if ( ! pDownload->IsPaused() && ! pDownload->IsMoving() ) pDownload->Pause();
00595 }
00596 }
00597
00598 Update();
00599 }
00600
00601 void CDownloadsWnd::OnUpdateDownloadsClear(CCmdUI* pCmdUI)
00602 {
00603 Prepare();
00604 pCmdUI->Enable( m_bSelNoPreview );
00605 }
00606
00607 void CDownloadsWnd::OnDownloadsClear()
00608 {
00609 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00610 CList<CDownload*> pList;
00611
00612 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00613 {
00614 CDownload* pDownload = Downloads.GetNext( pos );
00615 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
00616 }
00617
00618 while ( ! pList.IsEmpty() )
00619 {
00620 CDownload* pDownload = pList.RemoveHead();
00621
00622 if ( Downloads.Check( pDownload ) )
00623 {
00624 if ( pDownload->IsPreviewVisible() )
00625 {
00626
00627 }
00628 else if ( pDownload->IsCompleted() )
00629 {
00630 pDownload->Remove();
00631 }
00632 else if ( pDownload->IsStarted() )
00633 {
00634 CDeleteFileDlg dlg;
00635 dlg.m_sName = pDownload->m_sRemoteName;
00636 BOOL bShared = pDownload->IsShared();
00637
00638 pLock.Unlock();
00639 if ( dlg.DoModal() != IDOK ) break;
00640 pLock.Lock();
00641
00642 if ( Downloads.Check( pDownload ) )
00643 {
00644 dlg.Create( pDownload, bShared );
00645 pDownload->Remove();
00646 }
00647 }
00648 else
00649 {
00650 pDownload->Remove();
00651 }
00652 }
00653 }
00654
00655 Update();
00656 }
00657
00658 void CDownloadsWnd::OnUpdateDownloadsClearIncomplete(CCmdUI *pCmdUI)
00659 {
00660 Prepare();
00661
00662 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00663 pcCmdUI->Show( m_bSelNotCompleteAndNoPreview || ! m_bSelDownload );
00664 pCmdUI->Enable( m_bSelNotCompleteAndNoPreview );
00665 }
00666
00667 void CDownloadsWnd::OnDownloadsClearIncomplete()
00668 {
00669 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00670 CList<CDownload*> pList;
00671
00672 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00673 {
00674 CDownload* pDownload = Downloads.GetNext( pos );
00675 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
00676 }
00677
00678 while ( ! pList.IsEmpty() )
00679 {
00680 CDownload* pDownload = pList.RemoveHead();
00681
00682 if ( Downloads.Check( pDownload ) )
00683 {
00684 if ( ! pDownload->IsCompleted() && ! pDownload->IsPreviewVisible() )
00685 {
00686 if ( pDownload->IsStarted() )
00687 {
00688 CDeleteFileDlg dlg;
00689 dlg.m_sName = pDownload->m_sRemoteName;
00690 BOOL bShared = pDownload->IsShared();
00691
00692 pLock.Unlock();
00693 if ( dlg.DoModal() != IDOK ) break;
00694 pLock.Lock();
00695
00696 if ( Downloads.Check( pDownload ) ) dlg.Create( pDownload, bShared );
00697 }
00698
00699 if ( Downloads.Check( pDownload ) ) pDownload->Remove();
00700 }
00701 }
00702 }
00703
00704 Update();
00705 }
00706
00707 void CDownloadsWnd::OnUpdateDownloadsClearComplete(CCmdUI *pCmdUI)
00708 {
00709 Prepare();
00710 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00711 pcCmdUI->Show( m_bSelCompletedAndNoPreview );
00712 pCmdUI->Enable( m_bSelCompletedAndNoPreview );
00713 }
00714
00715 void CDownloadsWnd::OnDownloadsClearComplete()
00716 {
00717 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00718 {
00719 CDownload* pDownload = Downloads.GetNext( pos );
00720
00721 if ( pDownload->m_bSelected )
00722 {
00723 if ( pDownload->IsCompleted() && ! pDownload->IsPreviewVisible() )
00724 {
00725 pDownload->Remove();
00726 }
00727 }
00728 }
00729
00730 Update();
00731 }
00732
00733
00734 void CDownloadsWnd::OnUpdateDownloadsViewReviews(CCmdUI* pCmdUI)
00735 {
00736 Prepare();
00737
00738 pCmdUI->Enable( m_bSelHasReviews );
00739 }
00740
00741 void CDownloadsWnd::OnDownloadsViewReviews()
00742 {
00743 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00744
00745 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00746 {
00747 CDownload* pDownload = Downloads.GetNext( pos );
00748 if ( pDownload->m_bSelected && ( pDownload->GetReviewCount() >= 0 ) )
00749 {
00750
00751 CDownloadReviewDlg dlg( NULL, pDownload );
00752 pLock.Unlock();
00753
00754 dlg.DoModal();
00755 return;
00756 }
00757 }
00758 }
00759
00760 void CDownloadsWnd::OnUpdateDownloadsLaunch(CCmdUI* pCmdUI)
00761 {
00762 Prepare();
00763
00764 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00765 pcCmdUI->Show( m_bSelStartedAndNotMoving || ! m_bSelCompleted );
00766 pCmdUI->Enable( m_bSelCompleted || m_bSelStartedAndNotMoving );
00767 }
00768
00769 void CDownloadsWnd::OnDownloadsLaunch()
00770 {
00771 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00772 CList<CDownload*> pList;
00773 int nCount = 0;
00774
00775 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00776 {
00777 CDownload* pDownload = Downloads.GetNext( pos );
00778 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
00779 }
00780
00781 while ( ! pList.IsEmpty() )
00782 {
00783 CDownload* pDownload = pList.RemoveHead();
00784
00785 if ( Downloads.Check( pDownload ) )
00786 {
00787 CString strName = pDownload->m_sLocalName;
00788
00789 if ( pDownload->IsCompleted() )
00790 {
00791 if ( pDownload->m_pTorrent.m_nFiles > 1 )
00792 {
00793 CString strPath = DownloadGroups.GetCompletedPath( pDownload );
00794 strPath += _T("\\");
00795 strPath += pDownload->m_pTorrent.m_sName;
00796
00797 if ( GetFileAttributes( strPath ) & FILE_ATTRIBUTE_DIRECTORY )
00798 {
00799 ShellExecute( NULL, NULL, strPath, NULL, NULL, SW_SHOWNORMAL );
00800 continue;
00801 }
00802 }
00803
00804 if ( pDownload->m_bVerify == TS_FALSE )
00805 {
00806 CString strFormat, strMessage;
00807
00808 LoadString( strFormat, IDS_LIBRARY_VERIFY_FAIL );
00809 strMessage.Format( strFormat, (LPCTSTR)strName );
00810
00811 pLock.Unlock();
00812 UINT nResponse = AfxMessageBox( strMessage, MB_ICONEXCLAMATION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
00813 if ( nResponse == IDCANCEL ) break;
00814 pLock.Lock();
00815 if ( nResponse == IDNO ) continue;
00816 }
00817
00818 pLock.Unlock();
00819 if ( ! CFileExecutor::Execute( strName, FALSE ) ) break;
00820 pLock.Lock();
00821
00822 if ( ++nCount >= 5 ) break;
00823 }
00824 else if ( pDownload->IsStarted() && ! pDownload->IsMoving() )
00825 {
00826 if ( pDownload->CanPreview() )
00827 {
00828 pDownload->Preview( &pLock );
00829 }
00830 else
00831 {
00832 pLock.Unlock();
00833 if ( ! CFileExecutor::Execute( strName, FALSE ) ) break;
00834 pLock.Lock();
00835 }
00836
00837 if ( ++nCount >= 3 ) break;
00838 }
00839 }
00840 }
00841 }
00842
00843 void CDownloadsWnd::OnUpdateDownloadsLaunchComplete(CCmdUI* pCmdUI)
00844 {
00845 Prepare();
00846 if ( CCoolBarItem* pItem = CCoolBarItem::FromCmdUI( pCmdUI ) )
00847 pItem->Show( m_bSelCompleted );
00848 pCmdUI->Enable( m_bSelCompleted );
00849 }
00850
00851 void CDownloadsWnd::OnDownloadsLaunchComplete()
00852 {
00853 OnDownloadsLaunch();
00854 }
00855
00856 void CDownloadsWnd::OnUpdateDownloadsLaunchCopy(CCmdUI* pCmdUI)
00857 {
00858 Prepare();
00859 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00860 pcCmdUI->Show( m_bSelStartedAndNotMoving || ! m_bSelCompleted );
00861 pCmdUI->Enable( m_bSelCompleted || m_bSelStartedAndNotMoving );
00862 }
00863
00864 void CDownloadsWnd::OnDownloadsLaunchCopy()
00865 {
00866 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00867 CList<CDownload*> pList;
00868 int nCount = 0;
00869
00870 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00871 {
00872 CDownload* pDownload = Downloads.GetNext( pos );
00873 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
00874 }
00875
00876 while ( ! pList.IsEmpty() )
00877 {
00878 CDownload* pDownload = pList.RemoveHead();
00879
00880 if ( Downloads.Check( pDownload ) )
00881 {
00882 if ( pDownload->IsStarted() && ! pDownload->IsMoving() )
00883 {
00884 CString strType;
00885
00886 int nExtPos = pDownload->m_sLocalName.ReverseFind( '.' );
00887 if ( nExtPos > 0 ) strType = pDownload->m_sLocalName.Mid( nExtPos + 1 );
00888 strType = _T("|") + strType + _T("|");
00889
00890 if ( _tcsistr( Settings.Library.SafeExecute, strType ) == NULL ||
00891 pDownload->CanPreview() )
00892 {
00893 CString strFormat, strPrompt;
00894
00895 LoadString( strFormat, IDS_LIBRARY_CONFIRM_EXECUTE );
00896 strPrompt.Format( strFormat, (LPCTSTR)pDownload->m_sLocalName );
00897
00898 pLock.Unlock();
00899 int nResult = AfxMessageBox( strPrompt, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
00900 pLock.Lock();
00901
00902 if ( nResult == IDCANCEL ) break;
00903 else if ( nResult == IDNO ) continue;
00904 }
00905
00906 if ( Downloads.Check( pDownload ) ) pDownload->Preview( &pLock );
00907
00908 if ( ++nCount >= 3 ) break;
00909 }
00910 }
00911 }
00912 }
00913
00914 void CDownloadsWnd::OnUpdateDownloadsEnqueue(CCmdUI* pCmdUI)
00915 {
00916 Prepare();
00917 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
00918 pcCmdUI->Show( m_bSelStartedAndNotMoving || ! m_bSelCompleted );
00919 pCmdUI->Enable( m_bSelCompleted || m_bSelStartedAndNotMoving );
00920 }
00921
00922 void CDownloadsWnd::OnDownloadsEnqueue()
00923 {
00924 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00925 CList<CDownload*> pList;
00926
00927 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00928 {
00929 CDownload* pDownload = Downloads.GetNext( pos );
00930 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
00931 }
00932
00933 while ( ! pList.IsEmpty() )
00934 {
00935 CDownload* pDownload = pList.RemoveHead();
00936
00937 if ( Downloads.Check( pDownload ) )
00938 {
00939 if ( pDownload->IsStarted() )
00940 {
00941 CString strPath = pDownload->m_sLocalName;
00942 pLock.Unlock();
00943 CFileExecutor::Enqueue( strPath );
00944 pLock.Lock();
00945 }
00946 }
00947 }
00948 }
00949
00950 void CDownloadsWnd::OnUpdateDownloadsSources(CCmdUI* pCmdUI)
00951 {
00952 Prepare();
00953 pCmdUI->Enable( m_bSelMoreSourcesOK );
00954 }
00955
00956 void CDownloadsWnd::OnDownloadsSources()
00957 {
00958 int nCount = 0;
00959 CSingleLock pLock( &Transfers.m_pSection, TRUE );
00960
00961 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
00962 {
00963 CDownload* pDownload = Downloads.GetNext( pos );
00964
00965 if ( pDownload->m_bSelected )
00966 {
00967 if ( ! pDownload->IsMoving() )
00968 {
00969 nCount++;
00970 m_nMoreSourcesLimiter--;
00971 if ( m_nMoreSourcesLimiter >= 0 )
00972 {
00973 pDownload->FindMoreSources();
00974 }
00975 else
00976 {
00977
00978 theApp.Message( MSG_DEBUG, _T("Find more sources unable to start due to excessive network traffic") );
00979
00980 m_tMoreSourcesTimer = GetTickCount();
00981 if ( m_nMoreSourcesLimiter < -30 ) m_nMoreSourcesLimiter = -30;
00982 }
00983 }
00984 }
00985
00986
00987 if ( nCount >=3 ) break;
00988 }
00989
00990 Update();
00991 }
00992
00993 void CDownloadsWnd::OnUpdateDownloadsUrl(CCmdUI* pCmdUI)
00994 {
00995 Prepare();
00996 pCmdUI->Enable( m_bSelNotMoving );
00997 }
00998
00999 void CDownloadsWnd::OnDownloadsUrl()
01000 {
01001 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01002 CList<CDownload*> pList;
01003
01004 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01005 {
01006 CDownload* pDownload = Downloads.GetNext( pos );
01007 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
01008 }
01009
01010 while ( ! pList.IsEmpty() )
01011 {
01012 CDownload* pDownload = pList.RemoveHead();
01013
01014 if ( Downloads.Check( pDownload ) )
01015 {
01016 if ( ! pDownload->IsMoving() )
01017 {
01018 CDownloadDlg dlg( NULL, pDownload );
01019
01020 pLock.Unlock();
01021 if ( dlg.DoModal() != IDOK ) break;
01022 pLock.Lock();
01023
01024 if ( ! Downloads.Check( pDownload ) || pDownload->IsMoving() ) continue;
01025
01026 pDownload->AddSourceURL( dlg.m_pURL->m_sURL, FALSE );
01027 }
01028 }
01029 }
01030
01031 Update();
01032 }
01033
01034 void CDownloadsWnd::OnUpdateDownloadsBoost(CCmdUI* pCmdUI)
01035 {
01036 if ( Settings.Bandwidth.Downloads == 0 )
01037 {
01038 pCmdUI->Enable( FALSE );
01039 return;
01040 }
01041
01042 Prepare();
01043 pCmdUI->Enable( m_bSelBoostable );
01044 }
01045
01046 void CDownloadsWnd::OnDownloadsBoost()
01047 {
01048 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01049
01050 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01051 {
01052 CDownload* pDownload = Downloads.GetNext( pos );
01053
01054 if ( pDownload->m_bSelected )
01055 {
01056 if ( pDownload->GetTransferCount() && ! pDownload->IsBoosted() )
01057 {
01058 pDownload->Boost();
01059 }
01060 }
01061 }
01062
01063 Update();
01064 }
01065
01066 void CDownloadsWnd::OnUpdateDownloadsCopy(CCmdUI* pCmdUI)
01067 {
01068 Prepare();
01069 pCmdUI->Enable( m_bSelSHA1orED2K );
01070 }
01071
01072 void CDownloadsWnd::OnDownloadsCopy()
01073 {
01074 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01075 CList<CDownload*> pList;
01076
01077 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01078 {
01079 CDownload* pDownload = Downloads.GetNext( pos );
01080 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
01081 }
01082
01083 while ( ! pList.IsEmpty() )
01084 {
01085 CDownload* pDownload = pList.RemoveHead();
01086
01087 if ( Downloads.Check( pDownload ) && ( pDownload->m_bSHA1 || pDownload->m_bED2K ) )
01088 {
01089 CURLCopyDlg dlg;
01090 dlg.m_sName = pDownload->m_sRemoteName;
01091 dlg.m_bSHA1 = pDownload->m_bSHA1;
01092 dlg.m_pSHA1 = pDownload->m_pSHA1;
01093 dlg.m_bTiger = pDownload->m_bTiger;
01094 dlg.m_pTiger = pDownload->m_pTiger;
01095 dlg.m_bED2K = pDownload->m_bED2K;
01096 dlg.m_pED2K = pDownload->m_pED2K;
01097 dlg.m_bSize = pDownload->m_nSize != SIZE_UNKNOWN;
01098 dlg.m_nSize = pDownload->m_nSize;
01099 dlg.DoModal();
01100 }
01101 }
01102 }
01103
01104 void CDownloadsWnd::OnUpdateDownloadsShare(CCmdUI* pCmdUI)
01105 {
01106 #ifndef _DEBUG
01107 if ( Settings.eDonkey.EnableToday )
01108 {
01109 pCmdUI->Enable( FALSE );
01110 pCmdUI->SetCheck( TRUE );
01111 return;
01112 }
01113 #endif
01114
01115 Prepare();
01116 pCmdUI->Enable( m_bSelDownload && m_bSelShareConsistent );
01117 pCmdUI->SetCheck( m_bSelShareState );
01118 }
01119
01120 void CDownloadsWnd::OnDownloadsShare()
01121 {
01122 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01123
01124 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01125 {
01126 CDownload* pDownload = Downloads.GetNext( pos );
01127
01128 if ( pDownload->m_bSelected )
01129 {
01130 pDownload->Share( ! pDownload->IsShared() );
01131 }
01132 }
01133
01134 Update();
01135 }
01136
01137 void CDownloadsWnd::OnUpdateDownloadsMonitor(CCmdUI* pCmdUI)
01138 {
01139 Prepare();
01140 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
01141 pcCmdUI->Show( ! m_bSelCompleted );
01142 pCmdUI->Enable( m_bSelDownload && ! m_bSelCompleted );
01143 }
01144
01145 void CDownloadsWnd::OnDownloadsMonitor()
01146 {
01147 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01148 CList<CDownload*> pList;
01149
01150 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01151 {
01152 CDownload* pDownload = Downloads.GetNext( pos );
01153 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
01154 }
01155
01156 while ( ! pList.IsEmpty() )
01157 {
01158 CDownload* pDownload = pList.RemoveHead();
01159
01160 if ( Downloads.Check( pDownload ) && ! pDownload->IsMoving() )
01161 {
01162 pDownload->ShowMonitor( &pLock );
01163 }
01164 }
01165 }
01166
01167 void CDownloadsWnd::OnUpdateDownloadsTorrentInfo(CCmdUI* pCmdUI)
01168 {
01169 Prepare();
01170 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
01171 pcCmdUI->Show( m_bSelTorrent );
01172 pCmdUI->Enable( m_bSelTorrent );
01173 }
01174
01175 void CDownloadsWnd::OnDownloadsTorrentInfo()
01176 {
01177 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01178
01179 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01180 {
01181 CDownload* pDownload = Downloads.GetNext( pos );
01182
01183 if ( pDownload->m_bSelected && pDownload->m_pTorrent.IsAvailable() )
01184 {
01185 int nStart = pDownload->m_nStartTorrentDownloads;
01186 CTorrentTrackerDlg dlg( &pDownload->m_pTorrent, &nStart );
01187
01188
01189 pLock.Unlock();
01190 dlg.DoModal();
01191 pLock.Lock();
01192
01193 if ( Downloads.Check( pDownload ) )
01194 {
01195 pDownload->m_nStartTorrentDownloads = nStart;
01196
01197 if ( dlg.m_pInfo.IsAvailable() )
01198 {
01199 pDownload->m_pTorrent.m_sTracker = dlg.m_pInfo.m_sTracker;
01200 }
01201 }
01202
01203 break;
01204 }
01205 }
01206 }
01207
01208 void CDownloadsWnd::OnUpdateDownloadsEdit(CCmdUI *pCmdUI)
01209 {
01210 Prepare();
01211 pCmdUI->Enable( m_bSelNotMoving );
01212 }
01213
01214 void CDownloadsWnd::OnDownloadsEdit()
01215 {
01216 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01217
01218 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01219 {
01220 CDownload* pDownload = Downloads.GetNext( pos );
01221
01222 if ( pDownload->m_bSelected && ! pDownload->IsMoving() )
01223 {
01224 CDownloadEditDlg dlg( pDownload );
01225 pLock.Unlock();
01226 dlg.DoModal();
01227 break;
01228 }
01229 }
01230
01231 Update();
01232 }
01233
01234 void CDownloadsWnd::OnUpdateDownloadsMoveUp(CCmdUI* pCmdUI)
01235 {
01236 Prepare();
01237 pCmdUI->Enable( m_bSelDownload );
01238 }
01239
01240 void CDownloadsWnd::OnDownloadsMoveUp()
01241 {
01242 m_wndDownloads.MoveSelected( -1 );
01243 }
01244
01245 void CDownloadsWnd::OnUpdateDownloadsMoveDown(CCmdUI* pCmdUI)
01246 {
01247 Prepare();
01248 pCmdUI->Enable( m_bSelDownload );
01249 }
01250
01251 void CDownloadsWnd::OnDownloadsMoveDown()
01252 {
01253 m_wndDownloads.MoveSelected( 1 );
01254 }
01255
01256 void CDownloadsWnd::OnUpdateTransfersConnect(CCmdUI* pCmdUI)
01257 {
01258 Prepare();
01259 pCmdUI->Enable( m_bSelIdleSource && m_bConnectOkay );
01260 }
01261
01262 void CDownloadsWnd::OnTransfersConnect()
01263 {
01264 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01265
01266 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01267 {
01268 CDownload* pDownload = Downloads.GetNext( pos );
01269
01270 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; )
01271 {
01272 CDownloadSource* pNext = pSource->m_pNext;
01273 if ( pSource->m_bSelected && pSource->m_pTransfer == NULL )
01274 {
01275 if ( pSource->m_nProtocol != PROTOCOL_ED2K )
01276 {
01277 pSource->m_pDownload->Resume();
01278
01279 if ( pSource->m_bPushOnly )
01280 {
01281 pSource->PushRequest();
01282 }
01283 else if ( CDownloadTransfer* pTransfer = pSource->CreateTransfer() )
01284 {
01285 pTransfer->Initiate();
01286 }
01287 }
01288 }
01289 pSource = pNext;
01290 }
01291 }
01292
01293 Update();
01294 }
01295
01296 void CDownloadsWnd::OnUpdateTransfersDisconnect(CCmdUI* pCmdUI)
01297 {
01298 Prepare();
01299 pCmdUI->Enable( m_bSelActiveSource );
01300 }
01301
01302 void CDownloadsWnd::OnTransfersDisconnect()
01303 {
01304 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01305
01306 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01307 {
01308 CDownload* pDownload = Downloads.GetNext( pos );
01309
01310 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; )
01311 {
01312 CDownloadSource* pNext = pSource->m_pNext;
01313
01314 if ( pSource->m_bSelected && pSource->m_pTransfer != NULL )
01315 {
01316 pSource->m_pTransfer->Close( TS_TRUE );
01317 }
01318
01319 pSource = pNext;
01320 }
01321 }
01322
01323 Update();
01324 }
01325
01326 void CDownloadsWnd::OnUpdateTransfersForget(CCmdUI* pCmdUI)
01327 {
01328 Prepare();
01329 pCmdUI->Enable( m_bSelSource );
01330 }
01331
01332 void CDownloadsWnd::OnTransfersForget()
01333 {
01334 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01335
01336 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01337 {
01338 CDownload* pDownload = Downloads.GetNext( pos );
01339
01340 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; )
01341 {
01342 CDownloadSource* pNext = pSource->m_pNext;
01343 if ( pSource->m_bSelected ) pSource->Remove( TRUE, TRUE );
01344 pSource = pNext;
01345 }
01346 }
01347
01348 Update();
01349 }
01350
01351 void CDownloadsWnd::OnUpdateTransfersChat(CCmdUI* pCmdUI)
01352 {
01353
01354 if ( ! Settings.Community.ChatEnable )
01355 {
01356 pCmdUI->Enable( FALSE );
01357 return;
01358 }
01359
01360
01361 Prepare();
01362 pCmdUI->Enable( m_bSelHttpSource ||
01363 ( m_bSelDonkeySource && Settings.Community.ChatAllNetworks ) ||
01364 ( m_bSelSourceExtended && m_bSelSourceAcceptConnections ) );
01365 }
01366
01367 void CDownloadsWnd::OnTransfersChat()
01368 {
01369 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01370
01371 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01372 {
01373 CDownload* pDownload = Downloads.GetNext( pos );
01374
01375 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; pSource = pSource->m_pNext )
01376 {
01377 if ( pSource->m_bSelected )
01378 {
01379 if ( pSource->m_nProtocol == PROTOCOL_HTTP )
01380 ChatWindows.OpenPrivate( NULL, &pSource->m_pAddress, pSource->m_nPort, pSource->m_bPushOnly, pSource->m_nProtocol, &pSource->m_pServerAddress, pSource->m_nServerPort );
01381 else if ( pSource->m_bClientExtended && ! pSource->m_bPushOnly )
01382 ChatWindows.OpenPrivate( NULL, &pSource->m_pAddress, pSource->m_nPort, FALSE, PROTOCOL_G2 );
01383 else if ( pSource->m_nProtocol == PROTOCOL_ED2K )
01384 ChatWindows.OpenPrivate( NULL, &pSource->m_pAddress, pSource->m_nPort, pSource->m_bPushOnly, pSource->m_nProtocol, &pSource->m_pServerAddress, pSource->m_nServerPort );
01385 else
01386 theApp.Message( MSG_ERROR, _T("Error while initiating chat- Unable to select protocol") );
01387 }
01388 }
01389 }
01390 }
01391
01392 void CDownloadsWnd::OnUpdateBrowseLaunch(CCmdUI* pCmdUI)
01393 {
01394 Prepare();
01395 pCmdUI->Enable( m_bSelHttpSource || ( m_bSelSourceExtended && m_bSelSourceAcceptConnections ) );
01396 }
01397
01398 void CDownloadsWnd::OnBrowseLaunch()
01399 {
01400 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01401
01402 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01403 {
01404 CDownload* pDownload = Downloads.GetNext( pos );
01405
01406 for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource != NULL ; pSource = pSource->m_pNext )
01407 {
01408 if ( pSource->m_bSelected )
01409 {
01410 if ( pSource->m_nProtocol == PROTOCOL_HTTP )
01411 new CBrowseHostWnd( &pSource->m_pAddress, pSource->m_nPort, pSource->m_bPushOnly, &pSource->m_pGUID );
01412 else if ( pSource->m_bClientExtended )
01413 new CBrowseHostWnd( &pSource->m_pAddress, pSource->m_nPort, FALSE, NULL );
01414 }
01415 }
01416 }
01417 }
01418
01419 void CDownloadsWnd::OnUpdateDownloadsShowSources(CCmdUI* pCmdUI)
01420 {
01421 pCmdUI->SetCheck( Settings.Downloads.ShowSources );
01422 }
01423
01424 void CDownloadsWnd::OnDownloadsShowSources()
01425 {
01426 Settings.Downloads.ShowSources = ! Settings.Downloads.ShowSources;
01427 Update();
01428 }
01429
01430 void CDownloadsWnd::OnUpdateDownloadsFileDelete(CCmdUI* pCmdUI)
01431 {
01432 Prepare();
01433 if ( CCoolBarItem* pcCmdUI = CCoolBarItem::FromCmdUI( pCmdUI ) )
01434 pcCmdUI->Show( m_bSelCompleted );
01435 pCmdUI->Enable( m_bSelCompleted );
01436 }
01437
01438 void CDownloadsWnd::OnDownloadsFileDelete()
01439 {
01440 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01441 CList<CDownload*> pList;
01442
01443 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01444 {
01445 CDownload* pDownload = Downloads.GetNext( pos );
01446 if ( pDownload->m_bSelected ) pList.AddTail( pDownload );
01447 }
01448
01449 while ( ! pList.IsEmpty() )
01450 {
01451 CDownload* pDownload = pList.RemoveHead();
01452
01453 if ( Downloads.Check( pDownload ) && pDownload->IsCompleted() )
01454 {
01455 CDeleteFileDlg dlg;
01456 dlg.m_sName = pDownload->m_sRemoteName;
01457 CString strPath = pDownload->m_sLocalName;
01458
01459 pLock.Unlock();
01460 if ( dlg.DoModal() != IDOK ) break;
01461
01462 {
01463 CQuickLock oLibraryLock( Library.m_pSection );
01464 if ( CLibraryFile* pFile = LibraryMaps.LookupFileByPath( strPath ) )
01465 {
01466 dlg.Apply( pFile );
01467 }
01468 }
01469
01470 if ( Downloads.Check( pDownload ) ) pDownload->Remove( TRUE );
01471 }
01472 }
01473
01474 Update();
01475 }
01476
01477 void CDownloadsWnd::OnUpdateDownloadsRate(CCmdUI* pCmdUI)
01478 {
01479 Prepare();
01480 pCmdUI->Enable( m_bSelCompleted );
01481 }
01482
01483 void CDownloadsWnd::OnDownloadsRate()
01484 {
01485 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01486 CFilePropertiesSheet dlg;
01487 CStringList pList;
01488
01489 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01490 {
01491 CDownload* pDownload = Downloads.GetNext( pos );
01492 if ( pDownload->m_bSelected && pDownload->IsCompleted() )
01493 pList.AddTail( pDownload->m_sLocalName );
01494 }
01495
01496 pLock.Unlock();
01497
01498 while ( ! pList.IsEmpty() )
01499 {
01500 CString strPath = pList.RemoveHead();
01501
01502 CQuickLock oLock( Library.m_pSection );
01503 if ( CLibraryFile* pFile = LibraryMaps.LookupFileByPath( strPath ) )
01504 {
01505 dlg.Add( pFile->m_nIndex );
01506 }
01507 }
01508
01509 dlg.DoModal( 2 );
01510 Update();
01511 }
01512
01513 void CDownloadsWnd::OnDownloadsClearCompleted()
01514 {
01515 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01516 Downloads.ClearCompleted();
01517 Update();
01518 }
01519
01520 void CDownloadsWnd::OnDownloadsClearPaused()
01521 {
01522 CString strMessage;
01523 LoadString( strMessage, IDS_DOWNLOAD_CONFIRM_CLEAR_PAUSED );
01524
01525 if ( AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 ) == IDYES )
01526 {
01527 Downloads.ClearPaused();
01528 Update();
01529 }
01530 }
01531
01532 void CDownloadsWnd::OnUpdateDownloadsAutoClear(CCmdUI* pCmdUI)
01533 {
01534 pCmdUI->SetCheck( Settings.Downloads.AutoClear );
01535 }
01536
01537 void CDownloadsWnd::OnDownloadsAutoClear()
01538 {
01539 Settings.Downloads.AutoClear = ! Settings.Downloads.AutoClear;
01540 if ( Settings.Downloads.AutoClear ) OnTimer( 4 );
01541 }
01542
01543 void CDownloadsWnd::OnDownloadsFilterMenu()
01544 {
01545 CMenu* pMenu = Skin.GetMenu( _T("CDownloadsWnd.Filter") );
01546 m_wndToolBar.ThrowMenu( ID_DOWNLOADS_FILTER_MENU, pMenu, NULL, FALSE, TRUE );
01547 }
01548
01549 void CDownloadsWnd::OnUpdateDownloadsFilterAll(CCmdUI* pCmdUI)
01550 {
01551 pCmdUI->SetCheck( ( Settings.Downloads.FilterMask & DLF_ALL ) == DLF_ALL );
01552 }
01553
01554 void CDownloadsWnd::OnDownloadsFilterAll()
01555 {
01556 Settings.Downloads.FilterMask |= DLF_ALL;
01557 Update();
01558 }
01559
01560 void CDownloadsWnd::OnUpdateDownloadsFilterActive(CCmdUI* pCmdUI)
01561 {
01562 pCmdUI->SetCheck( ( Settings.Downloads.FilterMask & DLF_ACTIVE ) > 0 );
01563 }
01564
01565 void CDownloadsWnd::OnDownloadsFilterActive()
01566 {
01567 Settings.Downloads.FilterMask ^= DLF_ACTIVE;
01568 Update();
01569 }
01570
01571 void CDownloadsWnd::OnUpdateDownloadsFilterQueued(CCmdUI* pCmdUI)
01572 {
01573 pCmdUI->SetCheck( ( Settings.Downloads.FilterMask & DLF_QUEUED ) > 0 );
01574 }
01575
01576 void CDownloadsWnd::OnDownloadsFilterQueued()
01577 {
01578 Settings.Downloads.FilterMask ^= DLF_QUEUED;
01579 Update();
01580 }
01581
01582 void CDownloadsWnd::OnUpdateDownloadsFilterSources(CCmdUI* pCmdUI)
01583 {
01584 pCmdUI->SetCheck( ( Settings.Downloads.FilterMask & DLF_SOURCES ) > 0 );
01585 }
01586
01587 void CDownloadsWnd::OnDownloadsFilterSources()
01588 {
01589 Settings.Downloads.FilterMask ^= DLF_SOURCES;
01590 Update();
01591 }
01592
01593 void CDownloadsWnd::OnUpdateDownloadsFilterPaused(CCmdUI* pCmdUI)
01594 {
01595 pCmdUI->SetCheck( ( Settings.Downloads.FilterMask & DLF_PAUSED ) > 0 );
01596 }
01597
01598 void CDownloadsWnd::OnDownloadsFilterPaused()
01599 {
01600 Settings.Downloads.FilterMask ^= DLF_PAUSED;
01601 Update();
01602 }
01603
01604 void CDownloadsWnd::OnDownloadsSettings()
01605 {
01606 CSettingsManagerDlg::Run( _T("CDownloadsSettingsPage") );
01607 }
01608
01609 void CDownloadsWnd::OnUpdateDownloadGroupShow(CCmdUI* pCmdUI)
01610 {
01611 pCmdUI->Enable( Settings.General.GUIMode != GUI_BASIC );
01612 pCmdUI->SetCheck( Settings.General.GUIMode != GUI_BASIC && Settings.Downloads.ShowGroups );
01613 }
01614
01615 void CDownloadsWnd::OnDownloadGroupShow()
01616 {
01617 Settings.Downloads.ShowGroups = ! Settings.Downloads.ShowGroups;
01618
01619 CRect rc;
01620 GetClientRect( &rc );
01621 OnSize( SIZE_RESTORED, rc.right, rc.bottom );
01622
01623 Update();
01624 }
01625
01626 void CDownloadsWnd::OnDownloadsHelp()
01627 {
01628 CSingleLock pLock( &Transfers.m_pSection, TRUE );
01629 CDownload* pDownload = NULL;
01630
01631 for ( POSITION pos = Downloads.GetIterator() ; pos ; )
01632 {
01633 pDownload = Downloads.GetNext( pos );
01634 if ( pDownload->m_bSelected ) break;
01635 pDownload = NULL;
01636 }
01637
01638 if ( pDownload == NULL )
01639 {
01640 CHelpDlg::Show( _T("DownloadHelp.Select") );
01641 }
01642 else if ( pDownload->IsMoving() )
01643 {
01644 if ( pDownload->IsCompleted() )
01645 CHelpDlg::Show( _T("DownloadHelp.Completed") );
01646 else
01647 CHelpDlg::Show( _T("DownloadHelp.Moving") );
01648 }
01649 else if ( pDownload->IsPaused() )
01650 {
01651 if ( pDownload->m_bDiskFull )
01652 CHelpDlg::Show( _T("DownloadHelp.DiskFull") );
01653 else
01654 CHelpDlg::Show( _T("DownloadHelp.Paused") );
01655 }
01656 else if ( pDownload->GetProgress() == 1.0f && pDownload->IsStarted() )
01657 {
01658 CHelpDlg::Show( _T("DownloadHelp.Verifying") );
01659 }
01660 else if ( pDownload->IsDownloading() )
01661 {
01662 CHelpDlg::Show( _T("DownloadHelp.Downloading") );
01663 }
01664 else if ( ! pDownload->IsTrying() )
01665 {
01666 CHelpDlg::Show( _T("DownloadHelp.Queued") );
01667 }
01668 else if ( pDownload->GetSourceCount() > 0 )
01669 {
01670 CHelpDlg::Show( _T("DownloadHelp.Pending") );
01671 }
01672 else if ( pDownload->m_nSize == SIZE_UNKNOWN )
01673 {
01674 CHelpDlg::Show( _T("DownloadHelp.Searching") );
01675 }
01676 else if ( pDownload->m_bBTH && pDownload->IsTasking() )
01677 {
01678 CHelpDlg::Show( _T("DownloadHelp.Creating") );
01679 }
01680 else if ( pDownload->m_bTorrentTrackerError )
01681 {
01682 CHelpDlg::Show( _T("DownloadHelp.Tracker") );
01683 }
01684 else
01685 {
01686 CHelpDlg::Show( _T("DownloadHelp.Searching") );
01687 }
01688 }
01689
01691
01692
01693 void CDownloadsWnd::DragDownloads(CPtrList* pList, CImageList* pImage, const CPoint& ptScreen)
01694 {
01695 ASSERT( m_pDragList == NULL );
01696
01697 m_pDragList = pList;
01698 m_pDragImage = pImage;
01699
01700 CRect rcClient;
01701 GetClientRect( &rcClient );
01702 ClientToScreen( &rcClient );
01703
01704 ClipCursor( &rcClient );
01705 SetCapture();
01706 SetFocus();
01707 UpdateWindow();
01708
01709 OnSetCursor( NULL, 0, 0 );
01710
01711 CPoint ptStart( ptScreen );
01712 ScreenToClient( &ptStart );
01713
01714 CRect rcList;
01715 m_wndDownloads.GetWindowRect( &rcList );
01716 ScreenToClient( &rcList );
01717 m_pDragOffs = rcList.TopLeft();
01718 m_pDragOffs.y -= 4;
01719
01720 m_pDragImage->DragEnter( this, ptStart + m_pDragOffs );
01721 }
01722
01723 void CDownloadsWnd::CancelDrag()
01724 {
01725 if ( m_pDragList == NULL ) return;
01726
01727 ClipCursor( NULL );
01728 ReleaseCapture();
01729
01730 m_pDragImage->DragLeave( this );
01731 m_pDragImage->EndDrag();
01732 delete m_pDragImage;
01733 m_pDragImage = NULL;
01734
01735 delete m_pDragList;
01736 m_pDragList = NULL;
01737
01738 CPoint point( 0, 0 );
01739 m_wndTabBar.DropObjects( NULL, point );
01740 m_wndDownloads.DropObjects( NULL, point );
01741 }
01742
01743 void CDownloadsWnd::OnMouseMove(UINT nFlags, CPoint point)
01744 {
01745 if ( m_pDragList != NULL )
01746 {
01747 m_pDragImage->DragMove( point + m_pDragOffs );
01748 ClientToScreen( &point );
01749 m_wndTabBar.DropShowTarget( m_pDragList, point );
01750 m_wndDownloads.DropShowTarget( m_pDragList, point );
01751 }
01752
01753 CPanelWnd::OnMouseMove( nFlags, point );
01754 }
01755
01756 void CDownloadsWnd::OnLButtonUp(UINT nFlags, CPoint point)
01757 {
01758 if ( m_pDragList != NULL )
01759 {
01760 ClipCursor( NULL );
01761 ReleaseCapture();
01762
01763 m_pDragImage->DragLeave( this );
01764 m_pDragImage->EndDrag();
01765 delete m_pDragImage;
01766 m_pDragImage = NULL;
01767
01768 ClientToScreen( &point );
01769 m_wndTabBar.DropObjects( m_pDragList, point );
01770 m_wndDownloads.DropObjects( m_pDragList, point );
01771
01772 delete m_pDragList;
01773 m_pDragList = NULL;
01774
01775 Update();
01776 }
01777
01778 CPanelWnd::OnLButtonUp( nFlags, point );
01779 }
01780
01781 void CDownloadsWnd::OnRButtonDown(UINT nFlags, CPoint point)
01782 {
01783 if ( m_pDragList != NULL )
01784 {
01785 CancelDrag();
01786 return;
01787 }
01788
01789 CPanelWnd::OnRButtonDown( nFlags, point );
01790 }
01791
01792 void CDownloadsWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
01793 {
01794 if ( nChar == VK_ESCAPE ) CancelDrag();
01795 if ( m_pDragList != NULL ) OnSetCursor( NULL, 0, 0 );
01796 CPanelWnd::OnKeyDown( nChar, nRepCnt, nFlags );
01797 }
01798
01799 void CDownloadsWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
01800 {
01801 if ( m_pDragList ) OnSetCursor( NULL, 0, 0 );
01802 CPanelWnd::OnKeyUp( nChar, nRepCnt, nFlags );
01803 }
01804
01805 BOOL CDownloadsWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
01806 {
01807 if ( m_pDragList != NULL )
01808 {
01809 if ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 )
01810 SetCursor( m_hCursCopy );
01811 else
01812 SetCursor( m_hCursMove );
01813
01814 return TRUE;
01815 }
01816
01817 return CPanelWnd::OnSetCursor( pWnd, nHitTest, message );
01818 }