void CUtorrentSupplier::ImportUtorrentDownloads(informer fnInformer, void* pData, TImportResult& tImportResult, const CUtorrentSupplier* pUtorrentSupplier, LPSTR szPath) { CString uTorrentPath = szPath; vmsObjectSmartPtr <vmsUTorrentDownloadsDb> spUTorrentDownloads = _BT.CreateUTorrentDownloadsDbObject (); assert (spUTorrentDownloads != NULL); if (!spUTorrentDownloads) return; spUTorrentDownloads->ImportUtorrentDownloads(uTorrentPath + "resume.dat"); tImportResult.nFailure = 0; tImportResult.nSuccess = 0; tImportResult.nTotal = spUTorrentDownloads->getDownloadCount (); tImportResult.nUnprocessed = tImportResult.nTotal; if (fnInformer != 0 && pUtorrentSupplier != 0) fnInformer(tImportResult.nTotal, tImportResult.nTotal - tImportResult.nUnprocessed, pUtorrentSupplier->GetSupplierName(), pData); UINT nSize = spUTorrentDownloads->getDownloadCount (); for (UINT i=0; i < nSize; i++) { CImportResultGuard resultGuard(tImportResult); const vmsUTorrentDownloadsDb::Download *dl = spUTorrentDownloads->getDownload (i); CString pszFile = uTorrentPath + dl->strTorrentFileName.c_str(); CString pszTorrentUrl = "file://"; pszTorrentUrl += pszFile; CString outputFolder = dl->strOutputPath.c_str(); _pwndDownloads->CreateBtDownload(pszFile, pszTorrentUrl, TRUE, FALSE, outputFolder); resultGuard.Success(true); if (fnInformer != 0 && pUtorrentSupplier != 0) fnInformer(tImportResult.nTotal, tImportResult.nTotal - tImportResult.nUnprocessed, pUtorrentSupplier->GetSupplierName(), pData); } }
std::string HelpWriterContext::substituteMarkup(const std::string &text) const { char *resultStr = check_tty(text.c_str()); scoped_ptr_sfree resultGuard(resultStr); return std::string(resultStr); }
void COrbitSupplier::processDldImportedFromOrbit(const TOrbitDownload& tOrbitDownload, TImportResult& tImportResult) const { CImportResultGuard resultGuard(tImportResult); CString sDownloadFilePath; if (!retrieveDownloadFilePath(tOrbitDownload, sDownloadFilePath)) { return; } if (tOrbitDownload.sUrl.IsEmpty()) { return; } vmsDownloadSmartPtr dld; Download_CreateInstance (dld); if (FALSE == _pwndDownloads->CreateDownloadWithDefSettings (dld, tOrbitDownload.sUrl)) { return; } configureDownloadFileName(sDownloadFilePath, dld); if (!tOrbitDownload.bIsComplete) { ATLASSERT(false); } else { HANDLE hFile = CreateFile ((LPCTSTR)sDownloadFilePath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); DWORD dwSize = GetFileSize(hFile, NULL); CloseHandle(hFile); dld->pMgr->GetDownloadMgr ()->CreateCompleteDownload((UINT64)dwSize); } DLDS_LIST v; v.push_back (dld); _pwndDownloads->CreateDownloads (v, NULL); resultGuard.Success(true); }