mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Merge pull request #11235 from glassez/retry-fetch-rss
Allow to retry fetching RSS feeds. Closes #11168
This commit is contained in:
commit
19c70fd659
@ -121,6 +121,8 @@ namespace
|
|||||||
explicit DownloadHandlerImpl(const Net::DownloadRequest &downloadRequest, QObject *parent);
|
explicit DownloadHandlerImpl(const Net::DownloadRequest &downloadRequest, QObject *parent);
|
||||||
~DownloadHandlerImpl() override;
|
~DownloadHandlerImpl() override;
|
||||||
|
|
||||||
|
void cancel() override;
|
||||||
|
|
||||||
QString url() const;
|
QString url() const;
|
||||||
const Net::DownloadRequest downloadRequest() const;
|
const Net::DownloadRequest downloadRequest() const;
|
||||||
|
|
||||||
@ -416,6 +418,17 @@ namespace
|
|||||||
delete m_reply;
|
delete m_reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadHandlerImpl::cancel()
|
||||||
|
{
|
||||||
|
if (m_reply) {
|
||||||
|
m_reply->abort();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setError(errorCodeToString(QNetworkReply::OperationCanceledError));
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadHandlerImpl::assignNetworkReply(QNetworkReply *reply)
|
void DownloadHandlerImpl::assignNetworkReply(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
Q_ASSERT(reply);
|
Q_ASSERT(reply);
|
||||||
|
@ -104,6 +104,8 @@ namespace Net
|
|||||||
public:
|
public:
|
||||||
using QObject::QObject;
|
using QObject::QObject;
|
||||||
|
|
||||||
|
virtual void cancel() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(const DownloadResult &result);
|
void finished(const DownloadResult &result);
|
||||||
};
|
};
|
||||||
@ -118,6 +120,8 @@ namespace Net
|
|||||||
static void freeInstance();
|
static void freeInstance();
|
||||||
static DownloadManager *instance();
|
static DownloadManager *instance();
|
||||||
|
|
||||||
|
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
||||||
|
|
||||||
template <typename Context, typename Func>
|
template <typename Context, typename Func>
|
||||||
void download(const DownloadRequest &downloadRequest, Context context, Func &&slot);
|
void download(const DownloadRequest &downloadRequest, Context context, Func &&slot);
|
||||||
|
|
||||||
@ -137,7 +141,6 @@ namespace Net
|
|||||||
private:
|
private:
|
||||||
explicit DownloadManager(QObject *parent = nullptr);
|
explicit DownloadManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
DownloadHandler *download(const DownloadRequest &downloadRequest);
|
|
||||||
void applyProxySettings();
|
void applyProxySettings();
|
||||||
void handleReplyFinished(const QNetworkReply *reply);
|
void handleReplyFinished(const QNetworkReply *reply);
|
||||||
|
|
||||||
|
@ -125,11 +125,13 @@ void Feed::markAsRead()
|
|||||||
|
|
||||||
void Feed::refresh()
|
void Feed::refresh()
|
||||||
{
|
{
|
||||||
if (isLoading()) return;
|
if (isLoading())
|
||||||
|
m_downloadHandler->cancel();
|
||||||
|
|
||||||
// NOTE: Should we allow manually refreshing for disabled session?
|
// NOTE: Should we allow manually refreshing for disabled session?
|
||||||
|
|
||||||
Net::DownloadManager::instance()->download(m_url, this, &Feed::handleDownloadFinished);
|
m_downloadHandler = Net::DownloadManager::instance()->download(m_url);
|
||||||
|
connect(m_downloadHandler, &Net::DownloadHandler::finished, this, &Feed::handleDownloadFinished);
|
||||||
|
|
||||||
m_isLoading = true;
|
m_isLoading = true;
|
||||||
emit stateChanged(this);
|
emit stateChanged(this);
|
||||||
|
@ -41,6 +41,7 @@ class AsyncFileStorage;
|
|||||||
|
|
||||||
namespace Net
|
namespace Net
|
||||||
{
|
{
|
||||||
|
class DownloadHandler;
|
||||||
struct DownloadResult;
|
struct DownloadResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,5 +126,6 @@ namespace RSS
|
|||||||
QString m_dataFileName;
|
QString m_dataFileName;
|
||||||
QBasicTimer m_savingTimer;
|
QBasicTimer m_savingTimer;
|
||||||
bool m_dirty = false;
|
bool m_dirty = false;
|
||||||
|
Net::DownloadHandler *m_downloadHandler = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user