void CDlgUploading::OnAbort() { UPLS_LIST v; v.push_back (m_upl); _UplsMgr.DeleteUploads (v); Release (); }
BOOL fsUploadsMgr::SaveUploads(HANDLE hFile) { DWORD dw; UPLS_LIST list = m_vUploads; size_t cUploads = list.size () - m_cDontSaveUploads; if (FALSE == WriteFile (hFile, &cUploads, sizeof (size_t), &dw, NULL)) return FALSE; for (size_t i = 0; i < list.size (); i++) { vmsUploadSmartPtr upl = list [i]; if (upl->dwFlags & UF_DONTSAVETOFILE) continue; if (FALSE == WriteFile (hFile, &upl->bAutostart, sizeof (BOOL), &dw, NULL)) return FALSE; if (FALSE == WriteFile (hFile, &upl->nID, sizeof (UINT), &dw, NULL)) return FALSE; if (FALSE == WriteFile (hFile, &upl->dwFlags, sizeof (DWORD), &dw, NULL)) return FALSE; if (FALSE == WriteFile (hFile, &upl->dwState, sizeof (DWORD), &dw, NULL)) return FALSE; if (FALSE == WriteFile (hFile, &upl->dateAdded, sizeof (FILETIME), &dw, NULL)) return FALSE; if (FALSE == upl->log.Save (hFile)) return FALSE; if (FALSE == upl->pMgr->Save (hFile)) return FALSE; } return TRUE; }
DWORD WINAPI fsUploadsMgr::_threadDeleteUploads(LPVOID lp) { UPLS_LIST *pv = (UPLS_LIST*) lp; UINT msg = RegisterWindowMessage (_pszUploadsDeletedNotifyMsg); UINT nMemId = InterlockedIncrement (_UplsMgr.m_pnNextSharedMemId); CString str; str.Format (_pszSharedMemoryName, nMemId); vmsSharedDataT <UINT> gdata (str, FALSE, pv->size ()); int cUplds = 0; for (size_t i = 0; i < pv->size (); i++) { vmsUploadSmartPtr upl = pv->at (i); if ((upl->dwFlags & UF_READONLY) == 0) { upl->pMgr->StopUploading (TRUE); upl->pMgr->DeleteZipFile (); } if ((upl->dwFlags & UF_DONTNOTIFYABOUTDELETE) == 0) gdata [cUplds++] = upl->nID; } DWORD dw; if (cUplds) SendMessageTimeout (HWND_BROADCAST, msg, cUplds, nMemId, 0, 5000, &dw); delete pv; return 0; }
BOOL fsUploadsMgr::IsRunning() { UPLS_LIST v = m_vUploads; for (size_t i = 0; i < v.size (); i++) { if (v [i]->pMgr->IsRunning ()) return TRUE; } return FALSE; }
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)); }