本文整理汇总了C++中Download类的典型用法代码示例。如果您正苦于以下问题:C++ Download类的具体用法?C++ Download怎么用?C++ Download使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Download类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDownloadByDownloadId
bool DownloadManagerImpl::removeAndUpdateDownload(int downloadId, DownloadManager::DownloadStatus status)
{
Download *download = getDownloadByDownloadId(downloadId);
if (!download) {
qDebug() << "Could not find downloadId = " << downloadId;
// check download
checkDownloadQueue();
return false;
}
// Update status
download->setDownloadStatus(status);
if (!m_downloadDAO->updateDownload(download))
qDebug() << __PRETTY_FUNCTION__ << " Could not update information for download with id = " << downloadId;
// Remove the download from the downloading list
removeDownloadById(downloadId);
qDebug() << "Remove the download with downloadId = " << downloadId;
// check download
checkDownloadQueue();
return true;
}
示例2: dcassert
void DownloadManager::checkDownloads(UserConnection* aConn) {
dcassert(aConn->getDownload() == NULL);
QueueItem::Priority prio = QueueManager::getInstance()->hasDownload(aConn->getUser());
if(!startDownload(prio)) {
removeConnection(aConn);
return;
}
Download* d = QueueManager::getInstance()->getDownload(*aConn, aConn->isSet(UserConnection::FLAG_SUPPORTS_TTHL));
if(!d) {
Lock l(cs);
aConn->setState(UserConnection::STATE_IDLE);
idlers.push_back(aConn);
return;
}
aConn->setState(UserConnection::STATE_SND);
if(aConn->isSet(UserConnection::FLAG_SUPPORTS_XML_BZLIST) && d->getType() == Transfer::TYPE_FULL_LIST) {
d->setFlag(Download::FLAG_XML_BZ_LIST);
}
{
Lock l(cs);
downloads.push_back(d);
}
fire(DownloadManagerListener::Requesting(), d);
dcdebug("Requesting " I64_FMT "/" I64_FMT "\n", static_cast<long long int>(d->getStartPos()), static_cast<long long int>(d->getSize()));
aConn->send(d->getCommand(aConn->isSet(UserConnection::FLAG_SUPPORTS_ZLIB_GET)));
}
示例3: foreach
void DownloadManagerImpl::release()
{
m_mutexLocker.lock();
// Free downloads in the downloading list
foreach(Download *download, m_downloadingList) {
if (download == 0)
continue;
download->stop();
download->deleteLater();
download = 0;
}
m_downloadingList.clear();
for (int i = 0; i < m_downloadQueue.count(); i++) {
Download *download = m_downloadQueue.at(i);
if (download == 0)
continue;
download->stop();
download->deleteLater();
download = 0;
}
m_downloadQueue.clear();
m_mutexLocker.unlock();
if (m_dbConnection) {
m_dbConnection->close();
delete m_dbConnection;
m_dbConnection = 0;
}
if (m_downloadDAO) {
delete m_downloadDAO;
m_downloadDAO = 0;
}
}
示例4: locker
Download *DownloadManagerImpl::getDownloadByContactId(int contactId)
{
QMutexLocker locker(&m_mutexLocker);
for (int i = 0; i < m_downloadQueue.count(); i++) {
Download *download = m_downloadQueue.at(i);
if (download == 0)
continue;
Contact *contact = download->getContact();
if (contact == 0)
continue;
if (contact->getId() == contactId)
return download;
}
foreach(Download *download, m_downloadingList) {
if (download == 0)
continue;
Contact *contact = download->getContact();
if (contact == 0)
continue;
if (contact->getId() == contactId)
return download;
}
return 0;
}
示例5: curl_easy_setopt
FileDownloader::Download& FileDownloader::DownloadFile(std::string url) {
Download* download = new FileDownloader::Download();
download->container = this;
download->url = url;
activeDownloads.push_back(download);
MemoryStruct mem;
mem.memory = 0;
mem.size = 0;
CURL* curl = (CURL*)this->curl;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &mem);
CURLcode res = curl_easy_perform(curl);
DownloadedFile downloadedFile;
downloadedFile.url = download->url;
downloadedFile.data = mem.memory;
downloadedFile.size = (int)mem.size;
download->Completed(downloadedFile);
download->container->activeDownloads.erase(std::find(download->container->activeDownloads.begin(), download->container->activeDownloads.end(), download));
delete download;
DownloadComplete(downloadedFile);
return *download;
}
示例6: getDownloadByContactId
int DownloadManagerImpl::getCurrentRemainTimeByContact(int contactId)
{
Download *download = getDownloadByContactId(contactId);
if (download)
return download->getCurrentRemainTime();
return -1;
}
示例7: didCreateDestinationCallback
void didCreateDestinationCallback(CFURLDownloadRef, CFURLRef, const void* clientInfo)
{
// The concept of the ".download bundle" is internal to the Download, so we try to hide its
// existence by reporting the final destination was created, when in reality the bundle was created.
Download* download = downloadFromClientInfo(clientInfo);
download->didCreateDestination(download->destination());
}
示例8: SecureDownloadFinished
OSStatus SecureDownloadFinished (SecureDownloadRef downloadRef)
{
API_BEGIN
Required (downloadRef);
Download* d = (Download*) downloadRef;
d->Finalize ();
API_END
}
示例9: cancelDownload
void DownloadManager::cancelDownload(DownloadID downloadID)
{
Download* download = m_downloads.get(downloadID);
if (!download)
return;
download->cancel();
}
示例10: SecureDownloadUpdateWithData
OSStatus SecureDownloadUpdateWithData (SecureDownloadRef downloadRef, CFDataRef data)
{
API_BEGIN
Required (downloadRef);
Required (data);
Download* d = (Download*) downloadRef;
d->UpdateWithData (data);
API_END
}
示例11: l
int64_t DownloadManager::getRunningAverage() {
Lock l(cs);
int64_t avg = 0;
for(DownloadList::iterator i = downloads.begin(); i != downloads.end(); ++i) {
Download* d = *i;
avg += d->getAverageSpeed();
}
return avg;
}
示例12: SecureDownloadCopyCreationDate
OSStatus SecureDownloadCopyCreationDate (SecureDownloadRef downloadRef, CFDateRef* date)
{
API_BEGIN
Required (downloadRef);
Download* d = (Download*) downloadRef;
Required (date) = d->CopyDate ();
API_END
}
示例13: SecureDownloadCopyName
OSStatus SecureDownloadCopyName (SecureDownloadRef downloadRef, CFStringRef* name)
{
API_BEGIN
Required (downloadRef);
Download* d = (Download*) downloadRef;
Required (name) = d->CopyName ();
API_END
}
示例14: SecureDownloadCopyURLs
OSStatus SecureDownloadCopyURLs (SecureDownloadRef downloadRef, CFArrayRef* urls)
{
API_BEGIN
Required (downloadRef);
Download* d = (Download*) downloadRef;
Required (urls) = d->CopyURLs ();
API_END
}
示例15: SecureDownloadGetDownloadSize
OSStatus SecureDownloadGetDownloadSize (SecureDownloadRef downloadRef, SInt64* size)
{
API_BEGIN
Required (downloadRef);
Download* d = (Download*) downloadRef;
Required (size) = d->GetDownloadSize ();
API_END
}