mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
- Added some debug in rss
This commit is contained in:
parent
0fb78727d5
commit
c019b0d72c
@ -45,7 +45,7 @@ class downloadThread : public QThread {
|
|||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QWaitCondition condition;
|
QWaitCondition condition;
|
||||||
bool abort;
|
bool abort;
|
||||||
URLStream url_stream;
|
URLStream *url_stream;
|
||||||
QList<downloadThread*> subThreads;
|
QList<downloadThread*> subThreads;
|
||||||
bool subThread;
|
bool subThread;
|
||||||
|
|
||||||
@ -58,10 +58,11 @@ class downloadThread : public QThread {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
downloadThread(QObject* parent, bool subThread = false) : QThread(parent){
|
downloadThread(QObject* parent, bool subThread = false) : QThread(parent){
|
||||||
mutex.lock();
|
qDebug("Creating downloadThread");
|
||||||
abort = false;
|
abort = false;
|
||||||
mutex.unlock();
|
|
||||||
this->subThread = subThread;
|
this->subThread = subThread;
|
||||||
|
url_stream = 0;
|
||||||
|
qDebug("downloadThread created");
|
||||||
}
|
}
|
||||||
|
|
||||||
~downloadThread(){
|
~downloadThread(){
|
||||||
@ -69,10 +70,14 @@ class downloadThread : public QThread {
|
|||||||
abort = true;
|
abort = true;
|
||||||
condition.wakeOne();
|
condition.wakeOne();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
if(url_stream != 0)
|
||||||
|
delete url_stream;
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadUrl(QString url){
|
void downloadUrl(QString url){
|
||||||
|
if(url_stream == 0)
|
||||||
|
url_stream = new URLStream();
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
url_list << url;
|
url_list << url;
|
||||||
if(!isRunning()){
|
if(!isRunning()){
|
||||||
@ -139,31 +144,31 @@ class downloadThread : public QThread {
|
|||||||
std::cerr << "Error: could't create temporary file: " << (const char*)filePath.toUtf8() << '\n';
|
std::cerr << "Error: could't create temporary file: " << (const char*)filePath.toUtf8() << '\n';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
URLStream::Error status = url_stream.get((const char*)url.toUtf8());
|
URLStream::Error status = url_stream->get((const char*)url.toUtf8());
|
||||||
if(status){
|
if(status){
|
||||||
// Failure
|
// Failure
|
||||||
QString error_msg = QString(misc::toString(status).c_str());
|
QString error_msg = errorCodeToString(status);
|
||||||
qDebug("Download failed for %s, reason: %s", (const char*)url.toUtf8(), (const char*)error_msg.toUtf8());
|
qDebug("Download failed for %s, reason: %s", (const char*)url.toUtf8(), (const char*)error_msg.toUtf8());
|
||||||
url_stream.close();
|
url_stream->close();
|
||||||
emit downloadFailureST(this, url, errorCodeToString(status));
|
emit downloadFailureST(this, url, error_msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qDebug("Downloading %s...", (const char*)url.toUtf8());
|
qDebug("Downloading %s...", (const char*)url.toUtf8());
|
||||||
char cbuf[1024];
|
char cbuf[1024];
|
||||||
int len;
|
int len;
|
||||||
while(!url_stream.eof()) {
|
while(!url_stream->eof()) {
|
||||||
url_stream.read(cbuf, sizeof(cbuf));
|
url_stream->read(cbuf, sizeof(cbuf));
|
||||||
len = url_stream.gcount();
|
len = url_stream->gcount();
|
||||||
if(len > 0)
|
if(len > 0)
|
||||||
dest_file.write(cbuf, len);
|
dest_file.write(cbuf, len);
|
||||||
if(abort){
|
if(abort){
|
||||||
dest_file.close();
|
dest_file.close();
|
||||||
url_stream.close();
|
url_stream->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dest_file.close();
|
dest_file.close();
|
||||||
url_stream.close();
|
url_stream->close();
|
||||||
emit downloadFinishedST(this, url, filePath);
|
emit downloadFinishedST(this, url, filePath);
|
||||||
qDebug("download completed here: %s", (const char*)filePath.toUtf8());
|
qDebug("download completed here: %s", (const char*)filePath.toUtf8());
|
||||||
}else{
|
}else{
|
||||||
|
11
src/rss.h
11
src/rss.h
@ -161,18 +161,26 @@ class RssStream : public QObject{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RssStream(QString _url) {
|
RssStream(QString _url) {
|
||||||
|
qDebug("New rss stream created");
|
||||||
url = _url;
|
url = _url;
|
||||||
alias = url;
|
alias = url;
|
||||||
read = true;
|
read = true;
|
||||||
|
qDebug("Creating rss & ico downloadThreads");
|
||||||
downloaderRss = new downloadThread(this);
|
downloaderRss = new downloadThread(this);
|
||||||
downloaderIcon = new downloadThread(this);
|
downloaderIcon = new downloadThread(this);
|
||||||
|
qDebug("RSS & ico downloaders created");
|
||||||
connect(downloaderRss, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
connect(downloaderRss, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
||||||
connect(downloaderRss, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
connect(downloaderRss, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
||||||
|
qDebug("RSS is calling downloadUrl");
|
||||||
downloaderRss->downloadUrl(url);
|
downloaderRss->downloadUrl(url);
|
||||||
|
qDebug("downloadUrl called, ok");
|
||||||
// XXX: remove it when gif can be displayed
|
// XXX: remove it when gif can be displayed
|
||||||
iconPath = ":/Icons/rss.png";
|
iconPath = ":/Icons/rss.png";
|
||||||
|
qDebug("Calling getIcon");
|
||||||
getIcon();
|
getIcon();
|
||||||
|
qDebug("getIcon called");
|
||||||
lastRefresh.start();
|
lastRefresh.start();
|
||||||
|
qDebug("RSSStream constructed");
|
||||||
}
|
}
|
||||||
|
|
||||||
~RssStream(){
|
~RssStream(){
|
||||||
@ -451,10 +459,13 @@ class RssManager : public QObject{
|
|||||||
unsigned int streamListUrlSize = streamListUrl.size();
|
unsigned int streamListUrlSize = streamListUrl.size();
|
||||||
for(unsigned int i=0; i<streamListUrlSize; ++i){
|
for(unsigned int i=0; i<streamListUrlSize; ++i){
|
||||||
RssStream *stream = new RssStream(streamListUrl.at(i));
|
RssStream *stream = new RssStream(streamListUrl.at(i));
|
||||||
|
qDebug("Setting rss alias");
|
||||||
stream->setAlias(streamListAlias.at(i));
|
stream->setAlias(streamListAlias.at(i));
|
||||||
|
qDebug("RSS Alias set");
|
||||||
streamList.append(stream);
|
streamList.append(stream);
|
||||||
connect(stream, SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
|
connect(stream, SIGNAL(refreshFinished(QString, const unsigned short&)), this, SLOT(streamNeedRefresh(QString, const unsigned short&)));
|
||||||
}
|
}
|
||||||
|
qDebug("Streams loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the list of the rss stream for the next session
|
// save the list of the rss stream for the next session
|
||||||
|
@ -182,6 +182,7 @@
|
|||||||
|
|
||||||
// fills the streamList
|
// fills the streamList
|
||||||
void RSSImp::refreshStreamList() {
|
void RSSImp::refreshStreamList() {
|
||||||
|
qDebug("Refreshing stream list");
|
||||||
unsigned short nbstream = rssmanager.getNbStreams();
|
unsigned short nbstream = rssmanager.getNbStreams();
|
||||||
listStreams->clear();
|
listStreams->clear();
|
||||||
QList<QTreeWidgetItem *> streams;
|
QList<QTreeWidgetItem *> streams;
|
||||||
@ -190,6 +191,7 @@
|
|||||||
updateStreamName(i, NEWS);
|
updateStreamName(i, NEWS);
|
||||||
stream->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+rssmanager.getStream(i)->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+rssmanager.getStream(i)->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+rssmanager.getStream(i)->getLastRefreshElapsedString());
|
stream->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+rssmanager.getStream(i)->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+rssmanager.getStream(i)->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+rssmanager.getStream(i)->getLastRefreshElapsedString());
|
||||||
}
|
}
|
||||||
|
qDebug("Stream list refreshed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// fills the newsList
|
// fills the newsList
|
||||||
@ -294,6 +296,7 @@
|
|||||||
refreshTimeTimer.start(60000); // 1min
|
refreshTimeTimer.start(60000); // 1min
|
||||||
refreshStreamList();
|
refreshStreamList();
|
||||||
refreshTextBrowser();
|
refreshTextBrowser();
|
||||||
|
qDebug("RSSImp constructed");
|
||||||
}
|
}
|
||||||
|
|
||||||
RSSImp::~RSSImp(){
|
RSSImp::~RSSImp(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user