void CDownloadGroups::CreateDefault() { CQuickLock pLock( m_pSection ); CDownloadGroup* pGroup = GetSuperGroup(); pGroup = Add( _T("Audio") ); pGroup->SetSchema( CSchema::uriAudio ); pGroup->SetDefaultFilters(); pGroup = Add( _T("Video") ); pGroup->SetSchema( CSchema::uriVideo ); pGroup->SetDefaultFilters(); pGroup = Add( _T("Image") ); pGroup->SetSchema( CSchema::uriImage ); pGroup->SetDefaultFilters(); pGroup = Add( _T("BitTorrent") ); pGroup->SetSchema( CSchema::uriBitTorrent ); pGroup->SetDefaultFilters(); pGroup->SetFolder( Settings.Downloads.TorrentPath ); pGroup = Add( _T("Collection") ); pGroup->SetSchema( CSchema::uriCollection ); pGroup->SetDefaultFilters(); pGroup->SetFolder( Settings.Downloads.CollectionPath ); }
void CDownloadGroups::Serialize(CArchive& ar) { int nVersion = GROUPS_SER_VERSION; BYTE nState; if ( ar.IsStoring() ) { CleanTemporary(); ar << nVersion; ar.WriteCount( Downloads.GetCount() ); for ( POSITION pos = Downloads.GetIterator() ; pos ; ) { ar << Downloads.GetNext( pos )->m_nSerID; } ar.WriteCount( GetCount() ); for ( POSITION pos = GetIterator() ; pos ; ) { CDownloadGroup* pGroup = GetNext( pos ); nState = ( pGroup == m_pSuper ) ? 1 : 0; ar << nState; pGroup->Serialize( ar, nVersion ); } } else { ar >> nVersion; if ( nVersion <= 1 || nVersion > GROUPS_SER_VERSION ) AfxThrowUserException(); DWORD_PTR nCount = ar.ReadCount(); for ( ; nCount > 0 ; nCount-- ) { DWORD nDownload; ar >> nDownload; if ( CDownload* pDownload = Downloads.FindBySID( nDownload ) ) Downloads.Reorder( pDownload, NULL ); } if ( ( nCount = ar.ReadCount() ) != 0 ) Clear(); for ( ; nCount > 0 ; nCount-- ) { CDownloadGroup* pGroup = Add(); ar >> nState; if ( nState == 1 ) m_pSuper = pGroup; pGroup->Serialize( ar, nVersion ); } if ( nVersion < 5 ) { CDownloadGroup* pGroup = Add( _T("Image") ); pGroup->SetSchema( CSchema::uriImage ); pGroup->SetDefaultFilters(); pGroup = Add( _T("Collection") ); pGroup->SetSchema( CSchema::uriCollection ); pGroup->SetDefaultFilters(); } GetSuperGroup(); for ( POSITION pos = Downloads.GetIterator() ; pos ; ) { m_pSuper->Add( Downloads.GetNext( pos ) ); } } }