void CDlgUploading::OnAbort() { UPLS_LIST v; v.push_back (m_upl); _UplsMgr.DeleteUploads (v); Release (); }
void CUploadsWnd::OnDeleteUploads(int cUploads, UINT nIdMem) { CString str; str.Format (_pszSharedMemoryName, nIdMem); vmsSharedDataT <UINT> gdata (str, TRUE, cUploads); UPLS_LIST v; for (int i = 0; i < cUploads; i++) { vmsUploadSmartPtr upl = _UplsMgr.FindUploadById (gdata [i]); if (upl == NULL) continue; upl->dwFlags |= UF_DONTNOTIFYABOUTDELETE; v.push_back (upl); } if (v.size ()) _UplsMgr.DeleteUploads (v); }
void fsUploadsMgr::DeleteUploads(UPLS_LIST_REF v) { std::vector <size_t> vIndexes; size_t cUpls = v.size (); size_t nStart = 0; size_t i = 0; for (i = 0; i < cUpls; i++) vIndexes.push_back ((size_t)-1); for (i = 0; i < m_vUploads.size (); i++) { vmsUploadSmartPtr upl = m_vUploads [i]; for (size_t j = nStart; j < cUpls; j++) { if (upl == v.at (j)) { vIndexes [j] = i; size_t k = j; for (k = j; k > nStart && vIndexes [k - 1] != -1; k--) ; if (k == nStart) nStart = j + 1; break; } } } UPLS_LIST *pv = new UPLS_LIST; vmsUploadSmartPtr uplFake; Upload_CreateInstance (uplFake); for (i = 0; i < (UINT)v.size (); i++) { vmsUploadSmartPtr upl = v.at (i); int iIndex = vIndexes [i]; if (iIndex == -1) continue; upl->pMgr->SetEventFunc (NULL, 0); Event (upl, UME_UPLOAD_WILL_BE_DELETED); m_vUploads [iIndex] = uplFake; pv->push_back (upl); } UPLS_LIST v2; for (i = 0; i < m_vUploads.size (); i++) { if (m_vUploads [i] != uplFake) v2.push_back (m_vUploads [i]); } m_vUploads = v2; Event (NULL, UME_UPLOADS_WERE_DELETED); ProcessUploads (); DWORD dw; CloseHandle ( CreateThread (NULL, 0, _threadDeleteUploads, pv, 0, &dw)); }