void AdBlockDownloader::onDownloadFinished(QNetworkReply *reply) { reply->deleteLater(); this->_downloadreply = NULL; this->_filesdownloaded++; this->_tempfile.close(); if(this->_downloadtype == DownloadType::Filters) { if(this->_filesdownloaded == 1) /* Download the second file */ this->downloadFile(AdBlockDownloader::GITHUB_RAW_URL, AdBlockManager::TABLE_FILENAME, this->_adblockmanager->tableFile()); else if(this->_filesdownloaded == AdBlockDownloader::FILES_MAX) { this->_downloading = false; emit downloadingChanged(); emit downloadCompleted(); emit this->_adblockmanager->rulesChanged(); } } else if(this->_downloadtype == DownloadType::Hosts) { AdBlockHostsParser ahp; ahp.parse(this->_adblockmanager->hostsTmpFile(), this->_adblockmanager->hostsRgxFile()); this->_adblockmanager->updateHostsBlackList(); emit downloadingChanged(); emit downloadCompleted(); } }
void ConversationPage::folderSelected(const QModelIndex& index) { MPopupList *popupList = qobject_cast<MPopupList *>(sender()); if (!popupList) return; QStringListModel *model = (QStringListModel *) popupList->itemModel(); QStringList folders = model->stringList(); m_downloadFolder = QDir::homePath() + "/" + folders[index.row()]; QMailMessagePart::Location location = m_selectedAttachment.location(); location.setContainingMessageId(m_id); if (m_selectedAttachment.hasBody()) { // The content has already been downloaded to local device. No need to retrieve part from server. emit downloadCompleted(); return; } m_retrievalAction = new QMailRetrievalAction(this); connect(m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(activityChanged(QMailServiceAction::Activity))); m_retrievalAction->retrieveMessagePart(location); }
void GCF::IconCache::fetchIcon2(const QUrl& url) { if(!url.isValid()) return; d->mutex.lock(); if(d->fetchingList.contains(url)) { d->mutex.unlock(); return; } d->fetchingList.append(url); d->mutex.unlock(); GCF::AbstractFileDownloader* downloader = 0; downloader = GCF::AbstractFileDownloader::createDownloader( url.scheme() ); if( !downloader ) return; // cant help it. connect(downloader, SIGNAL(downloadCompleted()), this, SLOT(iconDownloaded())); connect(downloader, SIGNAL(downloadAborted(QString)), this, SLOT(iconDownloadAborted())); downloader->setAutoRemoveDownloadedFile(true); downloader->setUrl(url); GCF_UPDATER_LOG( QString("Fetching icon %1..").arg(url.toString()) ); downloader->download(); }
void WebViewDownloadItem::onDownloadSucceeded() { this->setCompleted(true); this->setError(false); this->setLastError(QString()); emit downloadCompleted(this->fileName()); }
void ConversationPage::activityChanged(QMailServiceAction::Activity activity) { if (QMailServiceAction *action = static_cast<QMailServiceAction*>(sender())) { if (activity == QMailServiceAction::Successful) { if (action == m_retrievalAction) { emit downloadCompleted(); } } } }
BeurerScaleManager::BeurerScaleManager(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) , usb(new Usb::UsbDownloader(this)) , usb_data(new Usb::UsbData(this)) { setWindowTitle("Beurer Scale Manager"); ui = new Ui::BeurerScaleManager(); ui->setupUi(this); connect(usb, SIGNAL(progress(int)), ui->progressDownload, SLOT(setValue(int))); connect(usb, SIGNAL(completed(QByteArray)), this, SLOT(downloadCompleted(QByteArray))); connect(usb, SIGNAL(error()), this, SLOT(downloadError())); }
void ConversationPage::processAttachments(const QMailMessage &message) { if (!message.status() & QMailMessageMetaData::HasAttachments) return; connect(this, SIGNAL(downloadCompleted()), this, SLOT(saveAttachment())); bool oneTimeFlag = true; for (uint i = 1; i < message.partCount(); ++i) { QMailMessagePart sourcePart = message.partAt(i); if (!(sourcePart.multipartType() == QMailMessagePartContainer::MultipartNone)) continue; if (oneTimeFlag) { MSeparator *separator = new MSeparator(); separator->setObjectName("Separator"); m_policy->addItem(separator); oneTimeFlag = false; } MStylableWidget *w = new MStylableWidget(this); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal); w->setLayout(layout); //% "Attached: " MLabel *label = new MLabel(qtTrId("xx_attached")); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); label->setObjectName ("AttachmentText"); layout->addItem(label); MButton *button = new MButton(sourcePart.displayName()); button->setObjectName ("AttachmentButton"); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); layout->addItem(button); //% "Download..." AttachmentAction *action = new AttachmentAction(qtTrId("xx_download_context_menu"), button, sourcePart); connect(action, SIGNAL(triggered()), this, SLOT(openAttachmentDownloadDialog())); //% "Open..." action = new AttachmentAction(qtTrId("xx_open_context_menu"), button, sourcePart); connect(action, SIGNAL(triggered()), this, SLOT(openAttachmentOpenDialog())); m_policy->addItem (w); } }
void QgsFileDownloader::onFinished() { // when canceled if ( ! mErrors.isEmpty() || mDownloadCanceled ) { mFile.close(); mFile.remove(); if ( mGuiNotificationsEnabled ) mProgressDialog->hide(); } else { // download finished normally if ( mGuiNotificationsEnabled ) mProgressDialog->hide(); mFile.flush(); mFile.close(); // get redirection url QVariant redirectionTarget = mReply->attribute( QNetworkRequest::RedirectionTargetAttribute ); if ( mReply->error() ) { mFile.remove(); error( tr( "Download failed: %1" ).arg( mReply->errorString() ) ); } else if ( !redirectionTarget.isNull() ) { QUrl newUrl = mUrl.resolved( redirectionTarget.toUrl() ); mUrl = newUrl; mReply->deleteLater(); mFile.open( QIODevice::WriteOnly ); mFile.resize( 0 ); mFile.close(); startDownload(); return; } else { emit downloadCompleted(); } } emit downloadExited(); this->deleteLater(); }
void FTPUpdate::commandFinished(int index, bool error) { if (index == listIndex) { if (!error) //Emit results if no error was received emit returnUpdateResults(newerVersionAvailable, newestVersion); listIndex = -1; } else if (index == downloadGetIndex) { file.close(); //Determine if the file was successfully downloaded emit downloadCompleted(error); downloadGetIndex = -1; } else if (index == downloadListIndex) { downloadListIndex = -1; } }
DownloadManager::DownloadManager(const QString &url, QString const & filename, QString const & title, QWidget *parent): QWidget( parent ), m_downloadManager( new Download ), m_buttonCancel( new QPushButton("Cancel")), m_buttonPause( new QPushButton( "Pause") ), m_buttonResume( new QPushButton("Resume") ), m_progressBar( new QProgressBar ), m_gLayout( new QGridLayout ) { m_progressBar->setRange( 1, 100 ); m_gLayout->addWidget( new QLabel(title), 0, 0 ); m_gLayout->addWidget( m_progressBar, 1, 0 ); m_gLayout->addWidget( m_buttonPause, 1, 1 ); m_gLayout->addWidget( m_buttonResume, 1, 2 ); m_gLayout->addWidget( m_buttonCancel, 1, 3 ); m_downloadManager->download( url, filename ); QObject::connect( m_downloadManager , SIGNAL(downloadProgress(int)), m_progressBar, SLOT(setValue(int)) ); QObject::connect( m_buttonPause, SIGNAL(clicked()), this, SLOT( paused()) ); QObject::connect( m_buttonCancel, SIGNAL(clicked()), this, SLOT(cancelled()) ); QObject::connect( m_buttonResume, SIGNAL(clicked()), this, SLOT(resumed()) ); QObject::connect( m_downloadManager, SIGNAL(downloadComplete()), this, SLOT(downloadCompleted()) ); setLayout( m_gLayout ); }
void PageDownloader::onReplyFinished(QNetworkReply* reply) { int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt(); qDebug() << QString("Reply from %1 finished with status code: %2.") .arg(mUrlString).arg(statusCode); if (statusCode == kOkStatusCode) { processReply(reply); } else if (statusCode == kMovedPermanentlyStatusCode || statusCode == kMovedTemporarilyStatusCode) { processRedirection(reply); } else { QString reasonPhrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute).toString(); qDebug() << QString("Error: %1").arg(reasonPhrase); emit errorOccuredAtUrl(mUrlString, reasonPhrase); emit downloadCompleted(QByteArray()); onDownloadCompleted(); } reply->deleteLater(); }
void PageDownloader::processReply(QNetworkReply* reply) { emit downloadCompleted(reply->readAll()); onDownloadCompleted(); }