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

DlgFolderScan.cpp

Go to the documentation of this file.
00001 //
00002 // DlgFolderScan.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 "Library.h"
00026 #include "DlgFolderScan.h"
00027 
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #undef THIS_FILE
00031 static char THIS_FILE[] = __FILE__;
00032 #endif
00033 
00034 BEGIN_MESSAGE_MAP(CFolderScanDlg, CSkinDialog)
00035         //{{AFX_MSG_MAP(CFolderScanDlg)
00036         ON_WM_TIMER()
00037         //}}AFX_MSG_MAP
00038 END_MESSAGE_MAP()
00039 
00040 CFolderScanDlg* CFolderScanDlg::m_pDialog = NULL;
00041 
00042 
00044 // CFolderScanDlg dialog
00045 
00046 CFolderScanDlg::CFolderScanDlg(CWnd* pParent) : CSkinDialog(CFolderScanDlg::IDD, pParent)
00047 {
00048         //{{AFX_DATA_INIT(CFolderScanDlg)
00049         //}}AFX_DATA_INIT
00050 
00051         m_nCookie               = 0;
00052         m_nFiles                = 0;
00053         m_nVolume               = 0;
00054         m_tLastUpdate   = 0;
00055         m_bActive               = FALSE;
00056 
00057         CSingleLock oLock( &Library.m_pSection );
00058         if ( oLock.Lock( 500 ) )
00059         {
00060                 m_pDialog       = this;
00061                 m_nCookie       = Library.m_nScanCount;
00062         }
00063 }
00064 
00065 CFolderScanDlg::~CFolderScanDlg()
00066 {
00067         if ( m_pDialog )
00068         {
00069                 CSingleLock pLock( &Library.m_pSection );
00070                 pLock.Lock( 500 );
00071                 m_pDialog = NULL;
00072         }
00073 }
00074 
00075 void CFolderScanDlg::DoDataExchange(CDataExchange* pDX)
00076 {
00077         CSkinDialog::DoDataExchange(pDX);
00078         //{{AFX_DATA_MAP(CFolderScanDlg)
00079         DDX_Control(pDX, IDC_SCAN_VOLUME, m_wndVolume);
00080         DDX_Control(pDX, IDC_SCAN_FILES, m_wndFiles);
00081         DDX_Control(pDX, IDC_SCAN_FILE, m_wndFile);
00082         //}}AFX_DATA_MAP
00083 }
00084 
00086 // CFolderScanDlg operations
00087 
00088 BOOL CFolderScanDlg::OnInitDialog()
00089 {
00090         CSkinDialog::OnInitDialog();
00091 
00092         SkinMe( _T("CFolderScanDlg"), IDR_LIBRARYFRAME );
00093 
00094         SetTimer( 1, 500, NULL );
00095         m_tLastUpdate   = 0;
00096         m_bActive               = TRUE;
00097 
00098         return TRUE;
00099 }
00100 
00101 void CFolderScanDlg::OnTimer(UINT nIDEvent)
00102 {
00103         CSingleLock pLock( &Library.m_pSection );
00104 
00105         if ( pLock.Lock( 50 ) && m_nCookie != Library.m_nScanCount )
00106         {
00107                 pLock.Unlock();
00108                 CSkinDialog::OnCancel();
00109         }
00110 }
00111 
00112 void CFolderScanDlg::OnCancel()
00113 {
00114         m_bActive = FALSE;
00115 
00116         if ( m_pDialog )
00117         {
00118                 CSingleLock pLock( &Library.m_pSection );
00119                 pLock.Lock( 500 );
00120                 m_pDialog = NULL;
00121         }
00122 
00123         CSkinDialog::OnCancel();
00124 }
00125 
00126 void CFolderScanDlg::Update(LPCTSTR pszName, DWORD nVolume)
00127 {
00128         CSingleLock oLock( &Library.m_pSection );
00129         if ( m_pDialog != NULL && oLock.Lock( 10 ) )
00130         {
00131                 m_pDialog->InstanceUpdate( pszName, nVolume );
00132         }
00133 }
00134 
00135 void CFolderScanDlg::InstanceUpdate(LPCTSTR pszName, DWORD nVolume)
00136 {
00137         DWORD dwNow = GetTickCount();
00138         CString strItem;
00139 
00140         m_nFiles ++;
00141         m_nVolume += nVolume;
00142 
00143         if ( m_bActive && dwNow - m_tLastUpdate > 250 )
00144         {
00145                 m_tLastUpdate = dwNow;
00146 
00147                 m_wndFile.SetWindowText( pszName );
00148 
00149                 strItem.Format( _T("%lu"), m_nFiles );
00150                 m_wndFiles.SetWindowText( strItem );
00151 
00152                 strItem = Settings.SmartVolume( m_nVolume, TRUE );
00153                 m_wndVolume.SetWindowText( strItem );
00154 
00155                 RedrawWindow();
00156         }
00157 }
00158 

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