/* * This function adds a file indicated by filehash to suspended_uploads_list */ uint16 CUploadQueue::SuspendUpload( const CMD4Hash& filehash ) { AddLogLineM( false, CFormat( _("Suspending upload of file: %s" ) ) % filehash.Encode() ); uint16 removed = 0; //Append the filehash to the list. suspended_uploads_list.push_back(filehash); wxString base16hash = filehash.Encode(); CClientPtrList::iterator it = m_uploadinglist.begin(); while (it != m_uploadinglist.end()) { CUpDownClient *potential = *it++; //check if the client is uploading the file we need to suspend if(potential->GetUploadFileID() == filehash) { //remove the unlucky client from the upload queue and add to the waiting queue RemoveFromUploadQueue(potential); m_waitinglist.push_back(potential); theStats::AddWaitingClient(); potential->SetUploadState(US_ONUPLOADQUEUE); potential->SendRankingInfo(); Notify_QlistRefreshClient(potential); Notify_ShowQueueCount(m_waitinglist.size()); removed++; } } return removed; }
/* * This function removes a file indicated by filehash from suspended_uploads_list. */ void CUploadQueue::ResumeUpload( const CMD4Hash& filehash ) { //Find the position of the filehash in the list and remove it. suspendlist::iterator it = std::find( suspended_uploads_list.begin(), suspended_uploads_list.end(), filehash ); if ( it != suspended_uploads_list.end() ) suspended_uploads_list.erase( it ); AddLogLineM( false, CFormat( _("Resuming uploads of file: %s" ) ) % filehash.Encode() ); }
bool CCanceledFileList::Init() { CFile file; CPath fullpath = CPath(theApp->ConfigDir + m_filename); if (!fullpath.FileExists()) { // This is perfectly normal. The file was probably either // deleted, or this is the first time running aMule. return false; } if (!file.Open(fullpath)) { AddLogLineM(true, CFormat(_("WARNING: %s cannot be opened.")) % m_filename); return false; } try { uint8 version = file.ReadUInt8(); if (version != CANCELEDFILE_VERSION) { AddLogLineM(true, _("WARNING: Canceled file list corrupted, contains invalid header.")); return false; } uint32 RecordsNumber = file.ReadUInt32(); AddDebugLogLineM(false, logKnownFiles, CFormat(wxT("Reading %i canceled files from file format 0x%02x.")) % RecordsNumber % version); for (uint32 i = 0; i < RecordsNumber; i++) { CMD4Hash hash; file.Read(hash.GetHash(), 16); AddDebugLogLineM(false, logKnownFiles, CFormat(wxT("Canceled file read: %s")) % hash.Encode()); if (!hash.IsEmpty()) { m_canceledFileList.insert(hash); } } AddDebugLogLineM(false, logKnownFiles, wxT("Finished reading canceled files")); return true; } catch (const CSafeIOException& e) { AddLogLineM(true, CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what()); } return false; }