mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Added download from url handling in GUI (still missing: search plugin update and rss)
This commit is contained in:
parent
2fd0de082c
commit
1fb848e9ed
6 changed files with 44 additions and 8 deletions
|
@ -49,6 +49,7 @@ class downloadThread : public QThread {
|
|||
|
||||
signals:
|
||||
void downloadFinished(const QString& url, const QString& file_path);
|
||||
void downloadFailure(const QString& url, const QString& reason);
|
||||
|
||||
public:
|
||||
downloadThread(QObject* parent) : QThread(parent){
|
||||
|
@ -78,6 +79,33 @@ class downloadThread : public QThread {
|
|||
}
|
||||
}
|
||||
|
||||
QString errorCodeToString(URLStream::Error status){
|
||||
switch(status){
|
||||
case URLStream::errUnreachable:
|
||||
return tr("Host is unreachable");
|
||||
case URLStream::errMissing:
|
||||
return tr("File was not found (404)");
|
||||
case URLStream::errDenied:
|
||||
return tr("Connection was denied");
|
||||
case URLStream::errInvalid:
|
||||
return tr("Url is invalid");
|
||||
case URLStream::errForbidden:
|
||||
return tr("Connection forbidden (403)");
|
||||
case URLStream::errUnauthorized:
|
||||
return tr("Connection was not authorized (401)");
|
||||
case URLStream::errRelocated:
|
||||
return tr("Content has moved (301)");
|
||||
case URLStream::errFailure:
|
||||
return tr("Connection failure");
|
||||
case URLStream::errTimeout:
|
||||
return tr("Connection was timed out");
|
||||
case URLStream::errInterface:
|
||||
return tr("Incorrect network interface");
|
||||
default:
|
||||
return tr("Unknown error");
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void run(){
|
||||
forever{
|
||||
|
@ -104,10 +132,10 @@ class downloadThread : public QThread {
|
|||
URLStream::Error status = url_stream.get((const char*)url.toUtf8());
|
||||
if(status){
|
||||
// Failure
|
||||
//TODO: handle this
|
||||
QString error_msg = QString(misc::toString(status).c_str());
|
||||
qDebug("Download failed for %s, reason: %s", (const char*)url.toUtf8(), (const char*)error_msg.toUtf8());
|
||||
url_stream.close();
|
||||
emit downloadFailure(url, errorCodeToString(status));
|
||||
continue;
|
||||
}
|
||||
qDebug("Downloading %s...", (const char*)url.toUtf8());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue