#include "StdAfx.h"
|
#include "MBDownloadMgr.h"
|
|
///////////////////////////////////
|
CMBDownFileInfo::CMBDownFileInfo()
|
{
|
m_bGetDocInfo = false;
|
m_nFileSize = 0 ;
|
m_nType = DOWNFILE_NONE;
|
m_nIsDir = 0;
|
}
|
|
CMBDownFileInfo::~CMBDownFileInfo()
|
{
|
}
|
|
CMBDownFileInfo::CMBDownFileInfo(const CMBDownFileInfo &downFileInfo)
|
{
|
m_nType = downFileInfo.m_nType;
|
m_strID = downFileInfo.m_strID;
|
m_strName = downFileInfo.m_strName;
|
m_strFileName = downFileInfo.m_strFileName;
|
m_strFileType = downFileInfo.m_strFileType;
|
m_strServerFlag = downFileInfo.m_strServerFlag;
|
m_strParentDir = downFileInfo.m_strParentDir;
|
m_strCanDownload = downFileInfo.m_strCanDownload;
|
m_strFileID = downFileInfo.m_strFileID;
|
m_nFileSize = downFileInfo.m_nFileSize;
|
m_nIsDir = downFileInfo.m_nIsDir;
|
|
m_strCatalogPath = downFileInfo.m_strCatalogPath;
|
m_strCabinetID = downFileInfo.m_strCabinetID;
|
m_strCabinetName = downFileInfo.m_strCabinetName;
|
m_bGetDocInfo = downFileInfo.m_bGetDocInfo;
|
}
|
|
CMBDownFileInfo& CMBDownFileInfo::operator=(const CMBDownFileInfo &downFileInfo)
|
{
|
if( this == &downFileInfo )
|
return *this;
|
|
m_nType = downFileInfo.m_nType;
|
m_strID = downFileInfo.m_strID;
|
m_strName = downFileInfo.m_strName;
|
m_strFileName = downFileInfo.m_strFileName;
|
m_strFileType = downFileInfo.m_strFileType;
|
m_strServerFlag = downFileInfo.m_strServerFlag;
|
m_strParentDir = downFileInfo.m_strParentDir;
|
m_strCanDownload = downFileInfo.m_strCanDownload;
|
m_strFileID = downFileInfo.m_strFileID;
|
m_nFileSize = downFileInfo.m_nFileSize;
|
m_nIsDir = downFileInfo.m_nIsDir;
|
|
m_strCatalogPath = downFileInfo.m_strCatalogPath;
|
m_strCabinetID = downFileInfo.m_strCabinetID;
|
m_strCabinetName = downFileInfo.m_strCabinetName;
|
m_bGetDocInfo = downFileInfo.m_bGetDocInfo;
|
return *this;
|
}
|
|
CString CMBDownFileInfo::GetDownloadFileName()
|
{
|
CString strName;
|
CString strFileName;
|
// ÏÈ´´½¨Îļþ
|
CStrFileUtils::CreateDir(m_strParentDir);
|
strFileName.Format(_T("%s\\%s"),m_strParentDir,m_strFileName);
|
if( !CStrFileUtils::IsExist(strFileName) )
|
{
|
return strFileName;
|
}
|
|
int nPos = m_strFileName.Find(_T("."));
|
strName = m_strFileName.Mid(0,nPos);
|
|
int nIndex = 1;
|
while( true )
|
{
|
strFileName.Format(_T("%s\\%s(%d)%s"),m_strParentDir,strName,nIndex,m_strFileType);
|
if( !CStrFileUtils::IsExist(strFileName) )
|
{
|
return strFileName;
|
}
|
nIndex++;
|
}
|
return strFileName;
|
}
|
|
CString CMBDownFileInfo::GetFullFileName()
|
{
|
CString strName;
|
CString strFileName;
|
CStrFileUtils::CreateDir(m_strParentDir);
|
strFileName.Format(_T("%s\\%s"),m_strParentDir,m_strFileName);
|
return strFileName;
|
}
|
// ÅжÏÊÇ·ñ»ñµÃ¹ýÎĵµÐÅÏ¢
|
bool CMBDownFileInfo::IsGetDocInfo()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
return m_bGetDocInfo;
|
}
|
|
// ÉèÖÃÒѵõ½¹ýÎĵµÐÅÏ¢
|
void CMBDownFileInfo::SetIsGetDocInfo()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
m_bGetDocInfo = true;
|
}
|
|
bool CMBDownFileInfo::ParseXML(CString &strXML,CString &strErrInfo)
|
{
|
if( strXML.IsEmpty() )
|
{
|
return true;
|
}
|
pugi::xml_document xmlDoc;
|
if (!xmlDoc.load(strXML))
|
{
|
return false;
|
}
|
//CString strSecretLvl; // Ãܼ¶
|
|
pugi::xml_node form = xmlDoc.child(_T("Doc"));
|
pugi::xml_node node = form;
|
m_strCanDownload = node.attribute(_T("CanDownload")).value();
|
m_strFileID = node.attribute(_T("FileID")).value();
|
m_strServerFlag = node.attribute(_T("FileServer")).value();
|
CString strFileSize = node.attribute(_T("FileSize")).value();
|
m_nFileSize = _ttol(strFileSize);
|
m_strFileName = node.child_value(_T("FileName"));
|
m_strCatalogPath = node.child_value(_T("CatalogPath")); // Ŀ¼·¾¶
|
m_strCabinetID = node.attribute(_T("CabinetID")).value(); // Îĵµ¹ñid
|
m_strCabinetName = node.attribute(_T("CabinetName")).value();; // ÎĵµÃû³Æ
|
|
return true;
|
}
|
|
///////////////////////////////////
|
CMBDownDirInfo::CMBDownDirInfo()
|
{
|
m_pDownloadFileMgr = NULL;
|
m_pDownloadFileMgr = new CMBDownloadFileMgr();
|
m_bGetDocList = false;
|
m_nType = DOWNDIR_NONE;
|
}
|
|
CMBDownDirInfo::~CMBDownDirInfo()
|
{
|
if( m_pDownloadFileMgr )
|
{
|
delete m_pDownloadFileMgr;
|
m_pDownloadFileMgr = NULL;
|
}
|
}
|
|
bool CMBDownDirInfo::IsGetDocList()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_bGetDocList;
|
}
|
|
void CMBDownDirInfo::SetIsGetDocList()
|
{
|
CSingleLock lock( &m_cs, true );
|
m_bGetDocList = true;
|
}
|
|
CMBDownloadFileMgr *CMBDownDirInfo::GetChildFileMgr()
|
{
|
return m_pDownloadFileMgr;
|
}
|
|
void CMBDownDirInfo::CreateDir()
|
{
|
CString strDir;
|
strDir.Format(_T("%s\\%s"),m_strParentDir,m_strName);
|
if( !CStrFileUtils::IsDirExit(strDir) )
|
{
|
// ´´½¨Ä¿Â¼
|
CStrFileUtils::CreateDir(strDir);
|
m_strCurDir = strDir;
|
return ;
|
}
|
int nIndex = 1;
|
while( true )
|
{
|
strDir.Format(_T("%s\\%s(%d)"),m_strParentDir,m_strName,nIndex);
|
if( !CStrFileUtils::IsDirExit(strDir) )
|
{
|
CStrFileUtils::CreateDir(strDir);
|
m_strCurDir = strDir;
|
return ;
|
}
|
nIndex++;
|
}
|
}
|
///////////////////////////////////
|
CMBDownloadFileMgr::CMBDownloadFileMgr(void)
|
{
|
RemoveAllDownloadDirInfo();
|
RemoveAllDownloadFileInfo();
|
m_nState = State_NoTraversing;
|
}
|
|
|
CMBDownloadFileMgr::~CMBDownloadFileMgr(void)
|
{
|
RemoveAllDownloadDirInfo();
|
RemoveAllDownloadFileInfo();
|
}
|
|
int CMBDownloadFileMgr::GetFileInfoCount()
|
{
|
return m_mapDownloadFileInfo.size();
|
}
|
|
int CMBDownloadFileMgr::GetDownloadDirCount()
|
{
|
return m_mapDownloadDirInfo.size();
|
}
|
|
int CMBDownloadFileMgr::GetState()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
return m_nState;
|
}
|
|
void CMBDownloadFileMgr::SetState( int nState )
|
{
|
CSingleLock lock( &m_cs, true );
|
|
m_nState = nState;
|
}
|
|
bool CMBDownloadFileMgr::AddDownloadFileInfo(CMBDownFileInfo *pDownFileInfo)
|
{
|
if( NULL == pDownFileInfo || pDownFileInfo->m_strID.IsEmpty() )
|
return false;
|
|
CMBDownloadFileInfoMap::iterator it;
|
CString strID;
|
|
strID = pDownFileInfo->m_strID;
|
it = m_mapDownloadFileInfo.find(strID);
|
|
// Èç¹ûÕҵõ½ ·µ»Ø
|
if( it != m_mapDownloadFileInfo.end() )
|
return false;
|
|
m_mapDownloadFileInfo[strID] = pDownFileInfo;
|
|
return true;
|
}
|
|
CMBDownFileInfo* CMBDownloadFileMgr::GetDownloadFileInfo( CString strID )
|
{
|
if( strID.IsEmpty() )
|
{
|
return NULL;
|
}
|
|
CMBDownloadFileInfoMap::iterator it;
|
CMBDownFileInfo *pDownFileInfo = NULL;
|
|
it = m_mapDownloadFileInfo.find(strID);
|
|
if( it!= m_mapDownloadFileInfo.end() )
|
pDownFileInfo = it->second;
|
|
return pDownFileInfo;
|
}
|
|
bool CMBDownloadFileMgr::RemoveAllDownloadFileInfo()
|
{
|
CMBDownloadFileInfoMap::iterator it;
|
CMBDownFileInfo *pDownFileInfo = NULL;
|
|
for( it = m_mapDownloadFileInfo.begin();it != m_mapDownloadFileInfo.end();it++ )
|
{
|
pDownFileInfo = it->second;
|
delete pDownFileInfo;
|
pDownFileInfo = NULL;
|
}
|
m_mapDownloadFileInfo.clear();
|
return true;
|
}
|
|
bool CMBDownloadFileMgr::AddDownloadDirInfo(CMBDownDirInfo *pDownDirInfo)
|
{
|
if( NULL == pDownDirInfo || pDownDirInfo->m_strID.IsEmpty() )
|
return false;
|
|
CMBDownloadDirInfoMap::iterator it;
|
CString strID;
|
|
strID = pDownDirInfo->m_strID;
|
it = m_mapDownloadDirInfo.find(strID);
|
|
// Èç¹ûÕҵõ½ ·µ»Ø
|
if( it != m_mapDownloadDirInfo.end() )
|
return false;
|
|
m_mapDownloadDirInfo[strID] = pDownDirInfo;
|
|
return true;
|
}
|
|
CMBDownDirInfo* CMBDownloadFileMgr::GetDownloadDirInfo( CString strID )
|
{
|
if( strID.IsEmpty() )
|
{
|
return NULL;
|
}
|
|
CMBDownloadDirInfoMap::iterator it;
|
CMBDownDirInfo *pDownDirInfo = NULL;
|
|
it = m_mapDownloadDirInfo.find(strID);
|
|
if( it!= m_mapDownloadDirInfo.end() )
|
pDownDirInfo = it->second;
|
|
return pDownDirInfo;
|
}
|
|
bool CMBDownloadFileMgr::RemoveAllDownloadDirInfo()
|
{
|
CMBDownloadDirInfoMap::iterator it;
|
CMBDownDirInfo *pDownDirInfo = NULL;
|
|
for( it = m_mapDownloadDirInfo.begin();it != m_mapDownloadDirInfo.end();it++ )
|
{
|
pDownDirInfo = it->second;
|
delete pDownDirInfo;
|
pDownDirInfo = NULL;
|
}
|
m_mapDownloadDirInfo.clear();
|
return true;
|
}
|
|
|
// ½âÎöxmlÊý¾Ý
|
bool CMBDownloadFileMgr::ParseUnitOrDepartXml( CString &strXml,CString strFrom,CString strCabinetID,CString strPath,CString &strErrInfo )
|
{
|
if( strXml.IsEmpty() )
|
{
|
strErrInfo = _T("CMBDownloadFileMgr::ParseUnitOrDepartXml,²ÎÊýstrXmlΪ¿Õ£¡");
|
return false;
|
}
|
|
CString strFileSize;
|
pugi::xml_document xmlDoc;
|
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("Catalog"));
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Catalog")))
|
{
|
CMBDownDirInfo *pDownDirInfo = new CMBDownDirInfo();
|
pDownDirInfo->m_nType = CMBDownDirInfo::DOWNDIR_UNITORDEPART;
|
pDownDirInfo->m_strID = node.attribute(_T("ID")).value(); // Ŀ¼id
|
pDownDirInfo->m_strName = node.child_value(_T("Name"));
|
pDownDirInfo->m_strParentDir = strPath; // ÏÂÔØÎļþĿ¼
|
pDownDirInfo->m_strCabinetID = strCabinetID; // Îĵµ¹ñid
|
pDownDirInfo->m_strPermit = node.attribute(_T("Permit")).value();
|
pDownDirInfo->m_strFrom = strFrom;
|
if( !AddDownloadDirInfo(pDownDirInfo) )
|
{
|
delete pDownDirInfo;
|
pDownDirInfo = NULL;
|
}
|
}
|
|
form = xmlDoc.child(_T("Body")).child(_T("Doc"));
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Doc")))
|
{
|
CMBDownFileInfo *pDownFileInfo = new CMBDownFileInfo();
|
pDownFileInfo->m_nType = CMBDownFileInfo::DOWNFILE_UNITORDEPART;
|
pDownFileInfo->m_strID = node.attribute(_T("ID")).value();
|
pDownFileInfo->m_strName = node.child_value(_T("Name"));
|
pDownFileInfo->m_strFileID = node.attribute(_T("FileID")).value();
|
pDownFileInfo->m_strFileName = node.attribute(_T("FileName")).value();
|
pDownFileInfo->m_strServerFlag = node.attribute(_T("FileServer")).value();;
|
pDownFileInfo->m_strParentDir = strPath;
|
pDownFileInfo->m_strCanDownload = node.attribute(_T("CanDownload")).value();
|
pDownFileInfo->m_strFileType = node.attribute(_T("FileType")).value();;
|
pDownFileInfo->m_strFrom = strFrom;
|
if( !AddDownloadFileInfo(pDownFileInfo) )
|
{
|
delete pDownFileInfo;
|
pDownFileInfo = NULL;
|
}
|
}
|
|
return true;
|
}
|
|
bool CMBDownloadFileMgr::ParsePsnXml( CString &strXml,CString strFrom,CString strCabinetID,CString strPath,CString &strErrInfo )
|
{
|
if( strXml.IsEmpty() )
|
{
|
strErrInfo = _T("CMBDownloadFileMgr::ParsePsnXml,²ÎÊýstrXmlΪ¿Õ£¡");
|
return false;
|
}
|
|
CString strFileSize;
|
pugi::xml_document xmlDoc;
|
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("Catalog"));
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Catalog")))
|
{
|
CMBDownDirInfo *pDownDirInfo = new CMBDownDirInfo();
|
pDownDirInfo->m_nType = CMBDownDirInfo::DOWNDIR_PSN;
|
pDownDirInfo->m_strID = node.attribute(_T("ID")).value(); // Ŀ¼id
|
pDownDirInfo->m_strName = node.child_value(_T("Name"));
|
pDownDirInfo->m_strParentDir = strPath; // ÏÂÔØÎļþĿ¼
|
pDownDirInfo->m_strCabinetID = strCabinetID; // Îĵµ¹ñid
|
pDownDirInfo->m_strPermit = node.attribute(_T("Permit")).value();
|
pDownDirInfo->m_strFrom = strFrom;
|
if( !AddDownloadDirInfo(pDownDirInfo) )
|
{
|
delete pDownDirInfo;
|
pDownDirInfo = NULL;
|
}
|
}
|
form = xmlDoc.child(_T("Body")).child(_T("Doc"));
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Doc")))
|
{
|
CMBDownFileInfo *pDownFileInfo = new CMBDownFileInfo();
|
pDownFileInfo->m_nType = CMBDownFileInfo::DOWNFILE_PSN;
|
pDownFileInfo->m_strID = node.attribute(_T("ID")).value();
|
pDownFileInfo->m_strName = node.child_value(_T("Name"));
|
pDownFileInfo->m_strFileID = node.attribute(_T("FileID")).value();
|
pDownFileInfo->m_strFileName = node.attribute(_T("FileName")).value();
|
pDownFileInfo->m_strServerFlag = node.attribute(_T("FileServer")).value();;
|
pDownFileInfo->m_strParentDir = strPath;
|
pDownFileInfo->m_strCanDownload = node.attribute(_T("CanDownload")).value();
|
pDownFileInfo->m_strFileType = node.attribute(_T("FileType")).value();;
|
pDownFileInfo->m_strFrom = strFrom;
|
if( !AddDownloadFileInfo(pDownFileInfo) )
|
{
|
delete pDownFileInfo;
|
pDownFileInfo = NULL;
|
}
|
}
|
|
return true;
|
}
|
|
bool CMBDownloadFileMgr::ParseVaultXml( CString &strXml,CString strFrom,CString strPath,CString &strErrInfo )
|
{
|
if( strXml.IsEmpty() )
|
{
|
strErrInfo = _T("CMBDownloadFileMgr::ParseUnitOrDepartXml,²ÎÊýstrXmlΪ¿Õ£¡");
|
return false;
|
}
|
|
CString strFileSize;
|
pugi::xml_document xmlDoc;
|
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
pugi::xml_node form = xmlDoc.child(_T("ObjList")).child(_T("Obj"));
|
//<Obj ID='%s' FileServer='%s' FileID='%s' FileType='%s' FileSize='%s' FileMD5='%s'><FileName><![CDATA[%s]]></FileName></Obj>
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Obj")))
|
{
|
CMBDownFileInfo *pDownFileInfo = new CMBDownFileInfo();
|
pDownFileInfo->m_nType = CMBDownFileInfo::DOWNFILE_NONE;
|
pDownFileInfo->m_strID = node.attribute(_T("ID")).value();
|
pDownFileInfo->m_strName = node.child_value(_T("FileName"));
|
pDownFileInfo->m_strFileID = node.attribute(_T("FileID")).value();
|
pDownFileInfo->m_strFileName = node.child_value(_T("FileName"));
|
pDownFileInfo->m_strServerFlag = node.attribute(_T("FileServer")).value();;
|
pDownFileInfo->m_strParentDir = strPath;
|
pDownFileInfo->m_strFileType = node.attribute(_T("FileType")).value();;
|
pDownFileInfo->m_strFrom = strFrom;
|
if( !AddDownloadFileInfo(pDownFileInfo) )
|
{
|
delete pDownFileInfo;
|
pDownFileInfo = NULL;
|
}
|
}
|
|
return true;
|
}
|
|
|
bool CMBDownloadFileMgr::ParseFireXml( CString &strXml,CString strFrom,CString strPath,CString &strErrInfo )
|
{
|
if( strXml.IsEmpty() )
|
{
|
strErrInfo = _T("CMBDownloadFileMgr::ParseUnitOrDepartXml,²ÎÊýstrXmlΪ¿Õ£¡");
|
return false;
|
}
|
|
CString strFileSize,strDirName;
|
pugi::xml_document xmlDoc;
|
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
pugi::xml_node form = xmlDoc.child(_T("ObjList")).child(_T("Obj"));
|
//<Obj ID='%s' FileServer='%s' FileID='%s' FileType='%s' FileSize='%s' FileMD5='%s'><FileName><![CDATA[%s]]></FileName></Obj>
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Obj")))
|
{
|
CMBDownFileInfo *pDownFileInfo = new CMBDownFileInfo();
|
pDownFileInfo->m_nType = CMBDownFileInfo::DOWNFILE_NONE;
|
pDownFileInfo->m_strID = node.attribute(_T("ID")).value();
|
pDownFileInfo->m_strName = node.child_value(_T("FileName"));
|
pDownFileInfo->m_strFileID = node.attribute(_T("FileID")).value();
|
pDownFileInfo->m_strFileName = node.child_value(_T("FileName"));
|
pDownFileInfo->m_strServerFlag = node.attribute(_T("FileServer")).value();
|
|
strDirName = CStrFileUtils::GetDirName( pDownFileInfo->m_strFileID );
|
|
pDownFileInfo->m_strParentDir = strPath + _T("\\") + strDirName;
|
pDownFileInfo->m_strFileType = node.attribute(_T("FileType")).value();
|
pDownFileInfo->m_strFrom = strFrom;
|
if( !AddDownloadFileInfo(pDownFileInfo) )
|
{
|
delete pDownFileInfo;
|
pDownFileInfo = NULL;
|
}
|
}
|
|
return true;
|
}
|
|
///////////////////////////////////////
|
CMBDownloadRootMgr::CMBDownloadRootMgr()
|
{
|
RemoveAllDownloadFileMgr();
|
}
|
|
CMBDownloadRootMgr::~CMBDownloadRootMgr()
|
{
|
RemoveAllDownloadFileMgr();
|
}
|
|
bool CMBDownloadRootMgr::AddDownloadFileMgr(CMBDownloadFileMgr *pDownloadFileMgr)
|
{
|
if( NULL == pDownloadFileMgr )
|
return false;
|
if( pDownloadFileMgr->GetFileInfoCount() > 0 || pDownloadFileMgr->GetDownloadDirCount() > 0 )
|
{
|
m_listDownloadFileMgr.push_back(pDownloadFileMgr);
|
}else
|
{
|
return false;
|
}
|
return true;
|
}
|
|
bool CMBDownloadRootMgr::RemoveAllDownloadFileMgr()
|
{
|
CMBDownloadFileMgrList::iterator it;
|
CMBDownloadFileMgr *pDownloadFileMgr = NULL;
|
|
for( it = m_listDownloadFileMgr.begin();it != m_listDownloadFileMgr.end();it++ )
|
{
|
pDownloadFileMgr = *it;
|
delete pDownloadFileMgr;
|
pDownloadFileMgr = NULL;
|
}
|
m_listDownloadFileMgr.clear();
|
|
return true;
|
}
|
|
///////////////////////////////////////
|
CMBDownloadMgr::CMBDownloadMgr()
|
{
|
RemoveAllDownloadRootMgr();
|
}
|
|
CMBDownloadMgr::~CMBDownloadMgr()
|
{
|
RemoveAllDownloadRootMgr();
|
}
|
|
bool CMBDownloadMgr::AddDownloadRootMgr(CMBDownloadRootMgr *pDownloadRootMgr,bool bEvent)
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( NULL == pDownloadRootMgr || pDownloadRootMgr->m_strRootPath.IsEmpty() )
|
return false;
|
|
|
//CString strRootPath;
|
|
m_vectorDownloadRootMgr.push_back(pDownloadRootMgr);
|
if( bEvent )
|
m_eventExe.Set();
|
|
//m_vectorDownloadRootMgr[strRootPath] = pDownloadRootMgr;
|
|
return true;
|
}
|
|
|
//CMBDownloadRootMgr* CMBDownloadMgr::GetDownloadRootMgr( CString strRootPath )
|
//{
|
// if( strRootPath.IsEmpty() )
|
// {
|
// return NULL;
|
// }
|
//
|
// CMBDownloadRootMgrVector::iterator it;
|
// CMBDownloadRootMgr *pDownloadRootMgr = NULL;
|
//
|
// it = m_mapDownloadRootMgr.find(strRootPath);
|
//
|
// if( it!= m_mapDownloadRootMgr.end() )
|
// pDownloadRootMgr = it->second;
|
//
|
// return pDownloadRootMgr;
|
//}
|
|
bool CMBDownloadMgr::RemoveAllDownloadRootMgr()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
CMBDownloadRootMgrVector::iterator it;
|
CMBDownloadRootMgr *pDownloadRootMgr = NULL;
|
|
for( it = m_vectorDownloadRootMgr.begin();it != m_vectorDownloadRootMgr.end();it++ )
|
{
|
pDownloadRootMgr = *it;
|
delete pDownloadRootMgr;
|
pDownloadRootMgr = NULL;
|
}
|
m_vectorDownloadRootMgr.clear();
|
return true;
|
}
|
|
|
bool CMBDownloadMgr::AttachThreadDownloadRoogMgr(CMBDownloadRootMgrVector &vectorDownloadRootMgr)
|
{
|
CSingleLock lock( &m_cs, true );
|
|
vectorDownloadRootMgr.clear();
|
vectorDownloadRootMgr = m_vectorDownloadRootMgr;
|
|
return true;
|
}
|
|
|
bool CMBDownloadMgr::RemoveDownloadRootMgr( CMBDownloadRootMgr *pDownloadRootMgr )
|
{
|
CSingleLock lock( &m_cs, true );
|
|
if( NULL == pDownloadRootMgr )
|
return false;
|
|
CMBDownloadRootMgrVector::iterator it = std::find(m_vectorDownloadRootMgr.begin( ), m_vectorDownloadRootMgr.end( ), pDownloadRootMgr); //²éÕÒ
|
if( it != m_vectorDownloadRootMgr.end( ) ){
|
|
m_vectorDownloadRootMgr.erase(it);
|
if( NULL != pDownloadRootMgr )
|
{
|
delete pDownloadRootMgr;
|
pDownloadRootMgr = NULL;
|
}
|
}
|
|
return true;
|
}
|
|
|
void CMBDownloadMgr::SetEventExe()
|
{
|
CSingleLock lock( &m_cs, true );
|
|
m_eventExe.Set();
|
}
|
|
void CMBDownloadMgr::SetEventShutdown()
|
{
|
CSingleLock lock( &m_cs, true );
|
m_eventShutdown.Set();
|
}
|
|
void CMBDownloadMgr::ResetEventExe()
|
{
|
CSingleLock lock( &m_cs, true );
|
m_eventExe.Reset();
|
}
|
|
void CMBDownloadMgr::ResetEventShutdown()
|
{
|
CSingleLock lock( &m_cs, true );
|
m_eventShutdown.Reset();
|
}
|
|
HANDLE CMBDownloadMgr::GetEventShutdownHandle()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_eventShutdown.GetEvent();
|
}
|
|
HANDLE CMBDownloadMgr::GetEventExeHandle()
|
{
|
CSingleLock lock( &m_cs, true );
|
return m_eventExe.GetEvent();
|
}
|
|
|
|
|