void DownloadManager::on_readyRead()
{
//qDebug() << "on_readyRead()";
void DownloadManager::on_readyRead()
{
//qDebug() << "on_readyRead()";
+ if(!WriteToFile()) {
+ qWarning() << "DownloadManager::on_readyRead(): Writing to file: "
+ << filepath_ << " failed.";
+ }
}
void DownloadManager::on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
}
void DownloadManager::on_downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-void DownloadManager::WriteToFile()
+bool DownloadManager::WriteToFile()
{
QByteArray readData = reply_->readAll();
if (readData.isEmpty()) {
qDebug() << "on_replyFinished(): No data available for reading";
} else {
{
QByteArray readData = reply_->readAll();
if (readData.isEmpty()) {
qDebug() << "on_replyFinished(): No data available for reading";
} else {
- file_.write(readData);
- /// @todo check file_.error()
+ // If writing failed, see error message.
+ if (file_.write(readData) == -1) {
+ qWarning() << file_.error();
+ return false;
+ }
void finished(QString filepath);
private:
void finished(QString filepath);
private:
private:
QNetworkAccessManager manager_;
private:
QNetworkAccessManager manager_;
void SearchPlugin::on_loadFinished(bool ok)
{
void SearchPlugin::on_loadFinished(bool ok)
{
- qDebug() << "on_loadFinished()";
+ qDebug() << "on_loadFinished(): success";
}
void SearchPlugin::on_searchResult(QWidget* resultWidget)
{
}
void SearchPlugin::on_searchResult(QWidget* resultWidget)
{
qDebug() << "on_searchResult()";
qDebug() << "on_searchResult()";
if (host_) {
host_->addPluginWidget(resultWidget, qtrapids::PluginHostInterface::TAB_PAGE);
}
if (host_) {
host_->addPluginWidget(resultWidget, qtrapids::PluginHostInterface::TAB_PAGE);
}
/// @todo We should also check MIME-type, instead of relying on file suffix.
/// @todo Also, after downloading, the torrent bencoding validity should be checked at plugin host..
if (fInfo.suffix() == "torrent") {
/// @todo We should also check MIME-type, instead of relying on file suffix.
/// @todo Also, after downloading, the torrent bencoding validity should be checked at plugin host..
if (fInfo.suffix() == "torrent") {
qDebug() << "IS TORRENT";
qDebug() << "IS TORRENT";
QString filename = fInfo.fileName();
// Destroy ongoing download, if any.
QString filename = fInfo.fileName();
// Destroy ongoing download, if any.
void SearchPlugin::on_downloadFinished(QString filepath)
{
void SearchPlugin::on_downloadFinished(QString filepath)
{
qDebug() << "TORRENT DOWNLOADED: " << filepath;
qDebug() << "TORRENT DOWNLOADED: " << filepath;
delete dlManager_;
dlManager_ = NULL;
host_->eventRequest(QVariant(filepath), qtrapids::PluginHostInterface::OPEN_FILE);
delete dlManager_;
dlManager_ = NULL;
host_->eventRequest(QVariant(filepath), qtrapids::PluginHostInterface::OPEN_FILE);