void CDownloadGroups::CreateDefault()
{
	CSingleLock pLock( &m_pSection, TRUE );

	CDownloadGroup* pGroup	= GetSuperGroup();

	pGroup = Add( _T("Audio") );
	pGroup->AddFilter( _T(".mp3") );
	pGroup->AddFilter( _T(".ogg") );
	pGroup->AddFilter( _T(".wav") );
	pGroup->AddFilter( _T(".wma") );
	pGroup->SetSchema( CSchema::uriMusicAlbum );

	pGroup = Add( _T("Video") );
	pGroup->AddFilter( _T(".asf") );
	pGroup->AddFilter( _T(".avi") );
	pGroup->AddFilter( _T(".mov") );
	pGroup->AddFilter( _T(".mpg") );
	pGroup->AddFilter( _T(".mpeg") );
	pGroup->AddFilter( _T(".ogm") );
	pGroup->AddFilter( _T(".wmv") );
	pGroup->SetSchema( CSchema::uriVideo );

	pGroup = Add( _T("BitTorrent") );
	pGroup->AddFilter( _T("torrent") );
	pGroup->SetSchema( CSchema::uriROM );
}
Exemple #2
0
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 );
}
Exemple #3
0
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 ) );
		}
	}
}