Ejemplo n.º 1
0
void CDownload::Remove()
{
	AbortTask();
	StopTrying();
	CloseTorrent();
	CloseTransfers();

	theApp.Message( MSG_NOTICE, IDS_DOWNLOAD_REMOVE, (LPCTSTR)GetDisplayName() );

	IsCompleted() ?
		CloseFile() :
		DeleteFile();

	DeletePreviews();

	if ( ! m_sPath.IsEmpty() )
	{
		DeleteFileEx( m_sPath + L".png", FALSE, FALSE, TRUE );
		DeleteFileEx( m_sPath + L".sav", FALSE, FALSE, TRUE );
		DeleteFileEx( m_sPath, FALSE, FALSE, TRUE );
		m_sPath.Empty();
	}

	Downloads.Remove( this );
}
Ejemplo n.º 2
0
void CDownload::OnMoved()
{
	CSingleLock pTransfersLock( &Transfers.m_pSection, TRUE );

	// Just completed torrent
	if ( IsTorrent() && IsFullyVerified() )
	{
		// Set FALSE to prevent sending 'stop' announce to tracker
		m_bTorrentRequested = FALSE;
		StopTrying();

		// Send 'completed' announce to tracker
		SendCompleted();

		// This torrent is now seeding
		m_bSeeding = TRUE;
		m_bVerify = TRI_TRUE;
		m_bTorrentStarted = TRUE;
		m_bTorrentRequested = TRUE;
	}
	else
	{
		if ( IsTorrent() )
			m_bTorrentRequested = TRUE;		// Explicitly set flag to send stop announce to tracker
		StopTrying();
		ClearSources();
	}

	ASSERT( ! m_sPath.IsEmpty() );
	const CString strPath = m_sPath;
	m_sPath.Empty();

	pTransfersLock.Unlock();

	DeleteFileEx( strPath + L".png", FALSE, FALSE, TRUE );
	DeleteFileEx( strPath + L".sav", FALSE, FALSE, TRUE );
	DeleteFileEx( strPath, FALSE, FALSE, TRUE );

	pTransfersLock.Lock();

	// Download finalized, tracker notified, set flags that we completed
	m_bComplete  = true;
	m_tCompleted = GetTickCount();
	//LibraryBuilder.m_bBusy = false;
}
Ejemplo n.º 3
0
BOOL CHostBrowser::OnNewFile(const CLibraryFile* pFile)
{
	//CQuickLock oTransfersLock( Transfers.m_pSection );

	if ( m_nProtocol == PROTOCOL_DC && ! m_sNick.IsEmpty() )
		return FALSE;

	CString strName;
	strName.Format( L"Files of %s.xml.bz2", (LPCTSTR)SafeFilename( m_sNick ) );
	if ( strName.CompareNoCase( pFile->m_sName ) != 0 )
		return FALSE;

	CQueryHit* pHits = NULL;

	if ( LoadDC( pFile->GetPath(), pHits ) )
	{
		if ( pHits != NULL )
			OnQueryHits( pHits );

		DeleteFileEx( pFile->GetPath(), TRUE, TRUE, TRUE );
	}

	return TRUE;
}
Ejemplo n.º 4
0
void CScanMemDlg::OnBtnDelFilesClicked()
{
    CDeleteDlg deleteDlg;
    int i;
    INT_PTR ret;
    int nItemCount = m_wndLvScanResult.GetItemCount ();

    TCHAR szMsg[MAX_PATH];
    int nSelItemCount = 0;
    for (i = 0; i < nItemCount; ++i) {
        if (m_wndLvScanResult.GetCheck (i))
            ++nSelItemCount;
    }
    if (nSelItemCount == 0) {
        MessageBox(TEXT("No item selected."), DEFCAPTION, MB_ICONWARNING);
        return;
    }
    ::wsprintf (szMsg, _T("%d objects will be deleted."), nSelItemCount);

    deleteDlg.Set_FilePathName (szMsg);
    ret = deleteDlg.DoModal ();
    if (ret == IDCANCEL)
        return;

    for (i = 0; i < nItemCount; ++i) {
        if (m_wndLvScanResult.GetCheck (i)) {
            CWaitCursor waitCursor;
            LPMWOBJ pMWObj = (LPMWOBJ) m_wndLvScanResult.GetItemData (i);
            if (pMWObj->dwType == MWT_PROCESS)
                KillProcess (pMWObj->dwProcessId);
            else
                StopAndDeleteService (pMWObj->szServiceName, pMWObj->dwProcessId > 0);

            // Delete the malware
            ret = DeleteFileEx (m_wndLvScanResult.GetItemText (i, 0), deleteDlg.Get_DelOpt(), 
                deleteDlg.Is_DelLockedFiles());
            if (ret == FL_SUCCESS) {
                // File was successfully deleted, so delete the item in list-view
                m_wndLvScanResult.DeleteItem (i--);
                --nItemCount;
                //m_wndLvScanResult.SetItemText (i, 2, _T("File was successfully deleted."));
            }
            else if (ret == FL_EWRITE) {
                if (deleteDlg.Is_DelLockedFiles ())
                    m_wndLvScanResult.SetItemText (i, 2, _T("File will be deleted at next restart."));
                else
                    m_wndLvScanResult.SetItemText (i, 2, _T("Cannot delete file, file is locked by another process."));
            }
            //else if (ret == FL_ENOFILE)
            //    m_wndLvScanResult.SetItemText (i, 2, _T("Cannot delete file, file doesn't exist."));
            else if (ret == FL_ENOTSUPT)
                m_wndLvScanResult.SetItemText (i, 2, _T("Cannot delete file, the operation is not supported."));
            else
                m_wndLvScanResult.SetItemText (i, 2, _T("Cannot delete file."));

        }   // if (m_wndLvScanResult.GetCheck (i))
    }   // for (int i = 0; i < nItemCount; ++i)

    if (m_wndLvScanResult.GetItemCount () == 0) {
        ((CButton*) GetDlgItem (IDC_CHKSELALL))->EnableWindow (FALSE);
        ((CButton*) GetDlgItem (IDC_BTNDELFILES))->EnableWindow (FALSE);
        ((CButton*) GetDlgItem (IDC_BTNMOVERENFILES))->EnableWindow (FALSE);
    }
}