Ejemplo n.º 1
0
LRESULT CWizardFoldersPage::OnWizardNext()
{
	CWaitCursor pCursor;

	CreateDirectory( m_sDownloadsPath );
	CreateDirectory( m_sIncompletePath );
	CreateDirectory( m_sTorrentsPath );

	if ( m_sIncompletePath != Settings.Downloads.IncompletePath && Settings.Library.UseCustomFolders )
	{
		// Set desktop.ini
		CLibraryFolder*	pFolderNew = new CLibraryFolder( NULL, m_sIncompletePath );
		pFolderNew->Maintain( TRUE );
		CLibraryFolder*	pFolderOld = new CLibraryFolder( NULL, Settings.Downloads.IncompletePath );
		pFolderOld->Maintain( FALSE );
	}

	Settings.Downloads.CompletePath		= m_sDownloadsPath;
	Settings.Downloads.IncompletePath	= m_sIncompletePath;
	Settings.Downloads.TorrentPath		= m_sTorrentsPath;

	UpdateData( FALSE );

	//LibraryFolders.AddFolder( m_sDownloadsPath );
	//LibraryFolders.AddFolder( m_sTorrentsPath );

	DoDonkeyImport();

	return 0;
}
Ejemplo n.º 2
0
LRESULT CWizardSharePage::OnWizardNext()
{
	CWaitCursor pCursor;

	if ( m_wndList.GetItemCount() == 0 )
	{
		if ( MsgBox( IDS_WIZARD_SHARE_CONFIRM, MB_ICONQUESTION|MB_YESNO ) == IDNO )
			return -1;
	}

	{
		CQuickLock oLock( Library.m_pSection );

		for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
		{
			CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

			int nItem = 0;
			for ( ; nItem < m_wndList.GetItemCount() ; nItem++ )
			{
				CString strFolder = m_wndList.GetItemText( nItem, 0 );
				if ( strFolder.CompareNoCase( pFolder->m_sPath ) == 0 )
				{
					if ( m_wndList.GetCheck(nItem) && ! pFolder->IsShared() )
						pFolder->SetShared( TRI_TRUE );
					else if ( ! m_wndList.GetCheck(nItem) && pFolder->IsShared() )
						pFolder->SetShared( TRI_FALSE );
					break;
				}
			}

			if ( nItem >= m_wndList.GetItemCount() )
				LibraryFolders.RemoveFolder( pFolder );
		}

		for ( int nItem = 0 ; nItem < m_wndList.GetItemCount() ; nItem++ )
		{
			LibraryFolders.AddFolder( m_wndList.GetItemText( nItem, 0 ), m_wndList.GetCheck(nItem) );
		}
	}

	CFolderScanDlg dlgScan;
	dlgScan.DoModal();

	return 0;
}
Ejemplo n.º 3
0
CLibraryFolder* CLibraryFolderCtrl::GetNextSelectedFolder(POSITION& pos) const
{
	CLibraryFolder* pFolder = NULL;

	do
	{
		if ( pos == NULL ) return NULL;

		HTREEITEM hItem = (HTREEITEM)pos;
		pos = (POSITION)GetNextSelectedItem( hItem );

		if ( hItem == m_hRoot ) continue;

		CList< HTREEITEM > pTree;

		while ( hItem != m_hRoot )
		{
			pTree.AddHead( hItem );
			hItem = GetParentItem( hItem );
		}

		CLibraryFolder* pLastFolder = NULL;

		for ( POSITION posTree = pTree.GetHeadPosition() ; posTree ; pLastFolder = pFolder )
		{
			hItem = pTree.GetNext( posTree );
			pFolder = (CLibraryFolder*)GetItemData( hItem );

			if ( pLastFolder )
			{
				if ( pLastFolder->CheckFolder( pFolder ) ) continue;
			}
			else
			{
				if ( LibraryFolders.CheckFolder( pFolder ) ) continue;
			}

			pFolder = NULL;
			break;
		}
	}
	while ( pFolder == NULL );

	return pFolder;
}
Ejemplo n.º 4
0
BOOL CShareManagerDlg::OnInitDialog()
{
	CSkinDialog::OnInitDialog();

	SkinMe( L"CShareManagerDlg", IDR_LIBRARYFRAME );

	CRect rc;
	m_wndList.GetClientRect( &rc );
	m_wndList.SetExtendedStyle( LVS_EX_DOUBLEBUFFER|LVS_EX_TRANSPARENTBKGND|LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP|LVS_EX_CHECKBOXES );
	m_wndList.InsertColumn( 0, _T("Folder"), LVCFMT_LEFT, rc.right - GetSystemMetrics( SM_CXVSCROLL ) );
	m_wndList.EnableToolTips( TRUE );
	ShellIcons.AttachTo( &m_wndList, 16 );	// m_wndList.SetImageList()

	if ( m_wndList.SetBkImage( Skin.GetWatermark( _T("CListCtrl") ) ) )		// || m_wndList.SetBkImage( Images.m_bmSystemWindow.m_hObject )		"System.Windows"
		m_wndList.SetExtendedStyle( LVS_EX_FULLROWSELECT|LVS_EX_TRANSPARENTBKGND|LVS_EX_LABELTIP|LVS_EX_CHECKBOXES );	// No LVS_EX_DOUBLEBUFFER
	else
	{
		m_wndList.SetBkColor( Colors.m_crWindow );
		m_wndList.SetTextBkColor( Colors.m_crWindow );
	}

	m_wndList.SetTextColor( Colors.m_crText );

	{
		CQuickLock oLock( Library.m_pSection );

		for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
		{
			CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

			m_wndList.InsertItem( LVIF_TEXT|LVIF_IMAGE, m_wndList.GetItemCount(),
				pFolder->m_sPath, 0, 0, SHI_FOLDER_OPEN, 0 );

			m_wndList.SetItemState( m_wndList.GetItemCount() - 1,
				UINT( ( pFolder->IsShared() != TRUE ? 1 : 2 ) << 12 ), LVIS_STATEIMAGEMASK );
		}
	}

	m_wndRemove.EnableWindow( FALSE );

	return TRUE;
}
Ejemplo n.º 5
0
void CShareManagerDlg::OnOK()
{
	{
		CQuickLock oLock( Library.m_pSection );

		for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
		{
			CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

			int nItem = 0;
			for ( ; nItem < m_wndList.GetItemCount() ; nItem++ )
			{
				CString strFolder = m_wndList.GetItemText( nItem, 0 );
				if ( strFolder.CompareNoCase( pFolder->m_sPath ) == 0 )
				{
					if ( m_wndList.GetCheck(nItem) && ! pFolder->IsShared() )
						pFolder->SetShared( TRI_TRUE );
					else if ( ! m_wndList.GetCheck(nItem) && pFolder->IsShared() )
						pFolder->SetShared( TRI_FALSE );
					break;
				}
			}

			if ( nItem >= m_wndList.GetItemCount() )
				LibraryFolders.RemoveFolder( pFolder );
		}

		for ( int nItem = 0 ; nItem < m_wndList.GetItemCount() ; nItem++ )
		{
			LibraryFolders.AddFolder( m_wndList.GetItemText( nItem, 0 ), m_wndList.GetCheck( nItem ) );
		}
	}

	CFolderScanDlg dlgScan;
	dlgScan.DoModal();

	CDialog::OnOK();
}
Ejemplo n.º 6
0
BOOL CLibraryWnd::OnCollection(LPCTSTR pszPath)
{
	CAlbumFolder* pFolder = NULL;
	CLibraryFolder* pLibFolder;
	CCollectionFile pCollection;
	CString strMessage;

	if ( ! pCollection.Open( pszPath ) )	// Verify specified collection is valid
	{
		// User clicked an invalid collection
		strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INVALID ), pszPath );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		return FALSE;
	}

	// Create the collection folder (in case it doesn't exist)
	CreateDirectory( Settings.Downloads.CollectionPath );
	// Add the collection folder to the library (in case it isn't there)
	pLibFolder = LibraryFolders.AddFolder( Settings.Downloads.CollectionPath );
	// Force a scan of it (in case watch library folders is disabled)
	pLibFolder = LibraryFolders.GetFolder( Settings.Downloads.CollectionPath );
	if ( pLibFolder != NULL ) pLibFolder->Scan();

	CSingleLock oLock( &Library.m_pSection, TRUE );
	if ( CLibraryFile* pFile = LibraryMaps.LookupFileByPath( pszPath, FALSE, TRUE ) )
	{
		// Collection IS already in the library

		// Re-mount the collection
		LibraryFolders.MountCollection( pFile->m_oSHA1, &pCollection );
		pFolder = LibraryFolders.GetCollection( pFile->m_oSHA1 );
		oLock.Unlock();
	}
	else	// Collection is not already in the main library
	{
		oLock.Unlock();
		// Check the collection folder
		CString strSource( pszPath ), strTarget;

		const int nName = strSource.ReverseFind( L'\\' );
		if ( nName >= 0 )
		{
			strTarget = Settings.Downloads.CollectionPath + strSource.Mid( nName );
			LibraryBuilder.RequestPriority( strTarget );
		}

		oLock.Lock();
		if ( CLibraryFile* pTargetFile = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
		{
			// Collection is already in the collection folder

			// Re-mount the collection
			LibraryFolders.MountCollection( pTargetFile->m_oSHA1, &pCollection );
			pFolder = LibraryFolders.GetCollection( pTargetFile->m_oSHA1 );
			oLock.Unlock();
		}
		else	// Collection is not already in collection folder
		{
			oLock.Unlock();

			if ( ! strTarget.IsEmpty() && CopyFile( strSource, strTarget, TRUE ) )
			{
				// Collection was copied into the collection folder

				// Force a scan of collection folder (in case watch library folders is disabled)
				if ( pLibFolder != NULL ) pLibFolder->Scan();

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFolder* pCollectionFolder = LibraryFolders.GetFolder(Settings.Downloads.CollectionPath ) )
				{
					pCollectionFolder->Scan();
				}
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
				}
				oLock.Unlock();
			}
			else if ( GetLastError() == ERROR_FILE_EXISTS )
			{
				// File with this name already exists:
				// We cannot copy the collection because it's already there, but it doesn't appear in the library.
				// The greatest probablility is that the file is there, but hasn't been added yet.
				// Best bet is to pretend everything is okay, since the delay it takes the user to respond may fix everything.

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Collection was already there: Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
					oLock.Unlock();
				}
				else	// File of this name exists in the folder, but does not appear in the library.
				{
					// Most likely cause- Corrupt file in collection folder.
					oLock.Unlock();
					strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
					MsgBox( strMessage, MB_ICONEXCLAMATION );
				}
			}
			else	// Was not able to copy collection to the collection folder for Unknown reason -Display an error message
			{
				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
				MsgBox( strMessage, MB_ICONEXCLAMATION );
			}
		}
	}

	if ( pFolder )
		Display( pFolder ); 	// Show the collection

	return ( pFolder != NULL );
}
Ejemplo n.º 7
0
BOOL CWizardSharePage::OnInitDialog()
{
	CWizardPage::OnInitDialog();

	Skin.Apply( _T("CWizardSharePage"), this );

	CRect rc;
	m_wndList.GetClientRect( &rc );
	m_wndList.SetExtendedStyle( LVS_EX_DOUBLEBUFFER|LVS_EX_TRANSPARENTBKGND|LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP|LVS_EX_CHECKBOXES );
	m_wndList.InsertColumn( 0, _T("Folder"), LVCFMT_LEFT, rc.Width() - GetSystemMetrics( SM_CXVSCROLL ) );
	m_wndList.EnableToolTips( TRUE );
	ShellIcons.AttachTo( &m_wndList, 16 );	// .SetImageList()

	if ( m_wndList.SetBkImage( Skin.GetWatermark( _T("CListCtrl") ) ) )		// || m_wndList.SetBkImage( Images.m_bmSystemWindow.m_hObject )		"System.Windows"
		m_wndList.SetExtendedStyle( LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP|LVS_EX_CHECKBOXES );	// No LVS_EX_DOUBLEBUFFER
	else
	{
		m_wndList.SetBkColor( Colors.m_crWindow );
		m_wndList.SetTextBkColor( Colors.m_crWindow  );
	}

	m_wndList.SetTextColor( Colors.m_crText );

	{
		CQuickLock oLock( Library.m_pSection );

		for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
		{
			CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

			m_wndList.InsertItem( LVIF_TEXT|LVIF_IMAGE, m_wndList.GetItemCount(),
				pFolder->m_sPath, 0, 0, SHI_FOLDER_OPEN, 0 );

			m_wndList.SetItemState( m_wndList.GetItemCount() - 1,
				UINT( ( pFolder->IsShared() != TRUE ? 1 : 2 ) << 12 ), LVIS_STATEIMAGEMASK );
		}

		CreateDirectory( Settings.Downloads.CompletePath );
		AddPhysicalFolder( Settings.Downloads.CompletePath );

		CreateDirectory( Settings.Downloads.CollectionPath );
		AddPhysicalFolder( Settings.Downloads.CollectionPath );

		CreateDirectory( Settings.Downloads.TorrentPath );
		AddPhysicalFolder( Settings.Downloads.TorrentPath );

		AddPhysicalFolder( (LPCTSTR)theApp.GetDownloadsFolder() );

		AddPhysicalFolder( (LPCTSTR)theApp.GetDocumentsFolder() );

		// ToDo: Check other common programs for download folder locations
		//strFolder = strPrograms + _T("\\Shareaza\\Downloads");
		//AddPhysicalFolder( strFolder );
		//strFolder = strPrograms + _T("\\Ares\\My Shared Folder");
		//AddPhysicalFolder( strFolder );
		//strFolder = strPrograms + _T("\\Neo Mule\\Incoming");
		//AddPhysicalFolder( strFolder );
		//CString strFolder = theApp.GetProgramFilesFolder() + _T("\\eMule\\Incoming");	// Takes several seconds
		AddPhysicalFolder( _T("c:\\Program Files\\eMule\\Incoming") );
#ifdef WIN64
		AddPhysicalFolder( _T("c:\\Program Files (x86)\\eMule\\Incoming") );
#endif

		AddRegistryFolder( HKEY_CURRENT_USER, _T("Software\\Shareaza\\Shareaza\\Downloads"), _T("CompletePath") );
		AddRegistryFolder( HKEY_CURRENT_USER, _T("Software\\Kazaa\\Transfer"), _T("DlDir0") );
		AddRegistryFolder( HKEY_CURRENT_USER, _T("Software\\Xolox"), _T("completedir") );
		AddRegistryFolder( HKEY_CURRENT_USER, _T("Software\\Xolox"), _T("sharedir") );
	}

	return TRUE;
}
Ejemplo n.º 8
0
void CDownloadsSettingsPage::OnOK()
{
	UpdateData( TRUE );

	AntiVirus.UpdateData( m_wndAntiVirus );

	// Figure out what the text in the queue limit box means
	DWORD nQueueLimit = 0;
	if ( IsLimited( m_sQueueLimit ) )
	{
		// Max queue is limited, calculate number
		int nPosition = 1, nCount = m_sQueueLimit.GetLength();
		while ( nCount-- )
		{
			TCHAR cCharacter = m_sQueueLimit.GetAt( nCount );
			if ( ( cCharacter >= '0' ) &&
				 ( cCharacter <= '9' ) )
			{
				nQueueLimit += ( ( cCharacter - '0') * nPosition );
				nPosition *= 10;
			}
		}
	}
	else
	{
		// Max queue is not limited
		nQueueLimit = 0;
	}

	// Check the queue limit value is okay
	if ( ( nQueueLimit > 0 ) && ( nQueueLimit < 2000 ) && ( ! Settings.Live.QueueLimitWarning ) &&
		 ( Settings.eDonkey.EnableToday || Settings.eDonkey.EnableAlways ) && ( Settings.Downloads.QueueLimit != (int)nQueueLimit ) )
	{
		// Warn the user about setting the max queue wait limit too low
		CString strMessage;
		LoadString( strMessage, IDS_SETTINGS_WARN_QUEUELIMIT );

		if ( AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNO ) == IDNO )
		{
			nQueueLimit = 0;
		}
		else
		{
			// Don't need to warn the user again.
			Settings.Live.QueueLimitWarning = TRUE;
		}
	}

	// Put new values in the settings.
	Settings.Downloads.CompletePath			= m_sDownloadsPath;
	Settings.Downloads.IncompletePath		= m_sIncompletePath;
	Settings.Downloads.MaxFiles				= m_nMaxDownFiles;
	Settings.Downloads.MaxTransfers			= m_nMaxDownTransfers;
	Settings.Downloads.MaxFileTransfers		= m_nMaxFileTransfers;
	Settings.Downloads.QueueLimit			= nQueueLimit;
	Settings.Bandwidth.Downloads			= static_cast< DWORD >( Settings.ParseVolume( m_sBandwidthLimit ) );
	Settings.Connection.RequireForTransfers	= m_bRequireConnect != FALSE;

	// Normalize data
	Settings.Normalize( &Settings.Downloads.MaxFiles );
	m_nMaxDownFiles		= Settings.Downloads.MaxFiles;
	Settings.Normalize( &Settings.Downloads.MaxTransfers );
	m_nMaxDownTransfers	= Settings.Downloads.MaxTransfers;
	Settings.Normalize( &Settings.Downloads.MaxFileTransfers );
	m_nMaxFileTransfers	= Settings.Downloads.MaxFileTransfers;
	Settings.Normalize( &Settings.Downloads.QueueLimit );

	// Redraw the text in the queue limit box (in case the limit changed)
	if ( Settings.Downloads.QueueLimit > 0 )
		m_sQueueLimit.Format( _T("%u"), Settings.Downloads.QueueLimit );
	else
		m_sQueueLimit = _T("MAX");

	// Display any data changes
	UpdateData( FALSE );

	CreateDirectory( m_sDownloadsPath );
	CreateDirectory( m_sIncompletePath );
	// CreateDirectory( m_sTorrentPath );

	if ( m_bDownloadsChanged )
	{
		if ( LibraryFolders.GetFolderCount() == 0 )
		{
			LibraryFolders.AddFolder( m_sDownloadsPath );
		}
		else if ( ! LibraryFolders.IsFolderShared( m_sDownloadsPath ) )
		{
			CString strFormat, strMessage;

			LoadString( strFormat, IDS_LIBRARY_DOWNLOADS_ADD );
			strMessage.Format( strFormat, (LPCTSTR)m_sDownloadsPath );

			if ( AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNO ) == IDYES )
			{
				CLibraryFolder* pFolder = LibraryFolders.AddFolder( m_sDownloadsPath );

				if ( pFolder )
				{
					LoadString( strMessage, IDS_LIBRARY_DOWNLOADS_SHARE );

					BOOL bShare = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNO ) == IDYES;

					CQuickLock oLock( Library.m_pSection );
					if ( LibraryFolders.CheckFolder( pFolder, TRUE ) )
						pFolder->SetShared( bShare ? TRI_TRUE : TRI_FALSE );
					Library.Update();
				}
			}
		}
	}

	CSettingsPage::OnOK();
}