mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
rss : show the number of NONREAD news (local test succeeded, need tests)
rss : clean the file rss.h rss : display the site favicon (local test succeeded, need tests) bug that i've noticed but not fixed : _ something create qt_temp files without delete them _ in dl list, columns disappear
This commit is contained in:
parent
e4915260e7
commit
7edc89638f
@ -13,21 +13,12 @@
|
||||
<string>Torrent addition dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="fileNameLbl" >
|
||||
<property name="text" >
|
||||
@ -57,21 +48,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="savePathTxt" />
|
||||
</item>
|
||||
@ -126,21 +108,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
|
@ -28,14 +28,10 @@
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QWaitCondition>
|
||||
#include <curl/curl.h>
|
||||
#include <iostream>
|
||||
#include <cc++/common.h>
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef CCXX_NAMESPACES
|
||||
using namespace std;
|
||||
using namespace ost;
|
||||
#endif
|
||||
#include "misc.h"
|
||||
|
||||
class downloadThread : public QThread {
|
||||
Q_OBJECT
|
||||
@ -45,11 +41,9 @@ class downloadThread : public QThread {
|
||||
QMutex mutex;
|
||||
QWaitCondition condition;
|
||||
bool abort;
|
||||
URLStream url_stream;
|
||||
|
||||
signals:
|
||||
void downloadFinished(const QString& url, const QString& file_path);
|
||||
void downloadFailure(const QString& url, const QString& reason);
|
||||
void downloadFinished(const QString& url, const QString& file_path, int return_code, const QString& errorBuffer);
|
||||
|
||||
public:
|
||||
downloadThread(QObject* parent) : QThread(parent){
|
||||
@ -79,33 +73,6 @@ 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{
|
||||
@ -117,41 +84,80 @@ class downloadThread : public QThread {
|
||||
QString url = url_list.takeFirst();
|
||||
mutex.unlock();
|
||||
qDebug("In Download thread RUN, mutex unlocked (got url)");
|
||||
// XXX: Trick to get a unique filename
|
||||
CURL *curl;
|
||||
QString filePath;
|
||||
QTemporaryFile *tmpfile = new QTemporaryFile();
|
||||
int return_code, response;
|
||||
// XXX: Trick to get a unique filename
|
||||
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||
if (tmpfile->open()) {
|
||||
filePath = tmpfile->fileName();
|
||||
}
|
||||
delete tmpfile;
|
||||
QFile dest_file(filePath);
|
||||
if(!dest_file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||
std::cerr << "Error: could't create temporary file: " << (const char*)filePath.toUtf8() << '\n';
|
||||
continue;
|
||||
if(abort)
|
||||
return;
|
||||
FILE *file = fopen((const char*)filePath.toUtf8(), "w");
|
||||
if(!file){
|
||||
std::cerr << "Error: could not open temporary file...\n";
|
||||
return;
|
||||
}
|
||||
URLStream::Error status = url_stream.get((const char*)url.toUtf8());
|
||||
if(status){
|
||||
// Failure
|
||||
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;
|
||||
// Initilization required by libcurl
|
||||
curl = curl_easy_init();
|
||||
if(!curl){
|
||||
std::cerr << "Error: Failed to init curl...\n";
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
qDebug("Downloading %s...", (const char*)url.toUtf8());
|
||||
char cbuf[1024];
|
||||
int len;
|
||||
while(!url_stream.eof()) {
|
||||
url_stream.read(cbuf, sizeof(cbuf));
|
||||
len = url_stream.gcount();
|
||||
if(len > 0){
|
||||
dest_file.write(cbuf, len);
|
||||
// Set url to download
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.toLocal8Bit().constData());
|
||||
qDebug("Url: %s", url.toLocal8Bit().constData());
|
||||
// Define our callback to get called when there's data to be written
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
||||
// Set destination file
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||
// Some SSL mambo jambo
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
// Disable progress meter
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
// Any kind of authentication
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
// Auto referrer
|
||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
|
||||
// Follow redirections
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
// Enable cookies
|
||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
|
||||
// We want error message:
|
||||
char errorBuffer[CURL_ERROR_SIZE];
|
||||
errorBuffer[0]=0; /* prevent junk from being output */
|
||||
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||
if(return_code){
|
||||
std::cerr << "Error: failed to set error buffer in curl\n";
|
||||
fclose(file);
|
||||
QFile::remove(filePath);
|
||||
return;
|
||||
}
|
||||
unsigned short retries = 0;
|
||||
bool to_many_users = false;
|
||||
do{
|
||||
// Perform Download
|
||||
return_code = curl_easy_perform(curl);
|
||||
// We want HTTP response code
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
||||
qDebug("HTTP response code: %d", response);
|
||||
if(response/100 == 5){
|
||||
to_many_users = true;
|
||||
++retries;
|
||||
SleeperThread::msleep(1000);
|
||||
}
|
||||
dest_file.close();
|
||||
url_stream.close();
|
||||
emit downloadFinished(url, filePath);
|
||||
qDebug("In Download thread RUN, signal emitted");
|
||||
}while(to_many_users && retries < 10 && response!=0);
|
||||
// Cleanup
|
||||
curl_easy_cleanup(curl);
|
||||
// Close tmp file
|
||||
fclose(file);
|
||||
emit downloadFinished(url, filePath, return_code, QString(errorBuffer));
|
||||
qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
|
||||
}else{
|
||||
qDebug("In Download thread RUN, mutex still locked (no urls) -> sleeping");
|
||||
condition.wait(&mutex);
|
||||
|
@ -13,21 +13,12 @@
|
||||
<string>Torrent Properties</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="torrentContent" >
|
||||
<property name="currentIndex" >
|
||||
@ -38,21 +29,12 @@
|
||||
<string>Main infos</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="fileName" >
|
||||
<property name="maximumSize" >
|
||||
@ -99,55 +81,28 @@
|
||||
<string>Torrent infos</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="savePath_lbl" >
|
||||
<property name="minimumSize" >
|
||||
@ -234,21 +189,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="save_path" >
|
||||
<property name="minimumSize" >
|
||||
@ -330,7 +276,9 @@
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -356,55 +304,28 @@
|
||||
<string>Current session</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="font" >
|
||||
@ -481,21 +402,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="upTotal" >
|
||||
<property name="text" >
|
||||
@ -569,25 +481,18 @@
|
||||
<string>Trackers</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -613,38 +518,20 @@
|
||||
<string>Tracker</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9" >
|
||||
<property name="font" >
|
||||
@ -665,25 +552,18 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="trackersURLS" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -692,21 +572,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
@ -777,21 +648,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
@ -862,21 +724,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10" >
|
||||
<property name="font" >
|
||||
@ -906,21 +759,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="maximumSize" >
|
||||
@ -983,21 +827,12 @@
|
||||
<string>Torrent content</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="font" >
|
||||
@ -1071,21 +906,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
|
39
src/rss.h
39
src/rss.h
@ -142,33 +142,15 @@ class RssStream : public QObject{
|
||||
QFile::remove(filePath);
|
||||
}
|
||||
filePath = file_path;
|
||||
// if(return_code){
|
||||
// // Download failed
|
||||
// qDebug("(download failure) "+file_path.toUtf8());
|
||||
// if(QFile::exists(filePath)) {
|
||||
// QFile::remove(filePath);
|
||||
// }
|
||||
// emit refreshFinished(url, NEWS);
|
||||
// return;
|
||||
// }
|
||||
openRss();
|
||||
emit refreshFinished(url, NEWS);
|
||||
}
|
||||
|
||||
void displayIcon(const QString&, const QString& file_path, int, const QString&) {
|
||||
/*if(QFile::exists(iconPath) && iconPath!=":/Icons/rss.png") {
|
||||
QFile::remove(iconPath);
|
||||
}
|
||||
// display the icon in the rss window
|
||||
void displayIcon(const QString&, const QString& file_path, int return_code, const QString&) {
|
||||
iconPath = file_path;
|
||||
|
||||
// XXX : remove it when we manage to dl the iconPath
|
||||
//iconPath = ":/Icons/rss.png";
|
||||
//iconPath = "/tmp/favicon.gif";
|
||||
|
||||
|
||||
if(return_code){
|
||||
// Download failed
|
||||
qDebug("(download failure) "+iconPath.toUtf8());
|
||||
if(QFile::exists(iconPath) && iconPath!=":/Icons/rss.png") {
|
||||
QFile::remove(iconPath);
|
||||
}
|
||||
@ -177,8 +159,7 @@ class RssStream : public QObject{
|
||||
return;
|
||||
}
|
||||
openIcon();
|
||||
emit refreshFinished(url, ICON);*/
|
||||
qDebug("******************Icone downloaded"+file_path.toUtf8());
|
||||
emit refreshFinished(url, ICON);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -193,7 +174,7 @@ class RssStream : public QObject{
|
||||
downloaderRss->downloadUrl(url);
|
||||
// XXX: remove it when gif can be displayed
|
||||
iconPath = ":/Icons/rss.png";
|
||||
//getIcon();
|
||||
getIcon();
|
||||
lastRefresh.start();
|
||||
}
|
||||
|
||||
@ -265,6 +246,15 @@ class RssStream : public QObject{
|
||||
return listItem.size();
|
||||
}
|
||||
|
||||
unsigned short getNbNonRead() const{
|
||||
int i=0, nbnonread=0;
|
||||
for(i=0; i<listItem.size(); i++) {
|
||||
if(!listItem.at(i)->isRead())
|
||||
nbnonread++;
|
||||
}
|
||||
return nbnonread;
|
||||
}
|
||||
|
||||
QList<RssItem*> getListItem() const{
|
||||
return listItem;
|
||||
}
|
||||
@ -285,13 +275,12 @@ class RssStream : public QObject{
|
||||
read = true;
|
||||
}
|
||||
|
||||
// FIXME : always return an empty file
|
||||
// download the icon from the adress
|
||||
void getIcon() {
|
||||
QUrl siteUrl(url);
|
||||
QString iconUrl = "http://"+siteUrl.host()+"/favicon.ico";
|
||||
connect(downloaderIcon, SIGNAL(downloadFinished(const QString&, const QString&, int, const QString&)), this, SLOT(displayIcon(const QString&, const QString&, int, const QString&)));
|
||||
downloaderIcon->downloadUrl(iconUrl);
|
||||
qDebug("******************Icone "+iconUrl.toUtf8());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -239,7 +239,7 @@
|
||||
}
|
||||
// on click, show the age of the stream
|
||||
if(type == LATENCY) {
|
||||
unsigned short nbitem = rssmanager.getStream(i)->getListSize();
|
||||
unsigned short nbitem = rssmanager.getStream(i)->getNbNonRead();
|
||||
listStreams->topLevelItem(i)->setText(0,rssmanager.getStream(i)->getAlias().toUtf8()+" ("+QString::number(nbitem,10).toUtf8()+")");
|
||||
if(nbitem==0)
|
||||
listStreams->topLevelItem(i)->setData(0,Qt::ForegroundRole, QVariant(QColor("red")));
|
||||
|
Loading…
Reference in New Issue
Block a user