2010-10-16 21:39:03 +04:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2010 Christophe Dumez, Arnaud Demaiziere
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
|
|
|
* Contact: chris@qbittorrent.org, arnaud@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
2011-01-29 14:57:52 +03:00
|
|
|
#include <QDebug>
|
2010-10-16 21:39:03 +04:00
|
|
|
#include "rssfeed.h"
|
|
|
|
#include "rssmanager.h"
|
|
|
|
#include "qbtsession.h"
|
|
|
|
#include "rssfolder.h"
|
2010-10-31 15:35:07 +03:00
|
|
|
#include "rsssettings.h"
|
2010-10-16 21:39:03 +04:00
|
|
|
#include "rssarticle.h"
|
2010-10-31 15:35:07 +03:00
|
|
|
#include "misc.h"
|
|
|
|
#include "rssdownloadrulelist.h"
|
2011-01-27 20:18:56 +03:00
|
|
|
#include "downloadthread.h"
|
2010-10-16 21:39:03 +04:00
|
|
|
|
2012-02-19 20:53:10 +04:00
|
|
|
RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString &url):
|
|
|
|
m_manager(manager), m_parent(parent), m_icon(":/Icons/oxygen/application-rss+xml.png"),
|
2011-01-27 20:18:56 +03:00
|
|
|
m_refreshed(false), m_downloadFailure(false), m_loading(false) {
|
|
|
|
qDebug() << Q_FUNC_INFO << url;
|
2011-06-05 20:08:30 +04:00
|
|
|
m_url = QUrl::fromEncoded(url.toUtf8()).toString();
|
2011-01-27 20:18:56 +03:00
|
|
|
// Listen for new RSS downloads
|
2012-02-19 20:53:10 +04:00
|
|
|
connect(manager->rssDownloader(), SIGNAL(downloadFinished(QString,QString)), SLOT(handleFinishedDownload(QString,QString)));
|
|
|
|
connect(manager->rssDownloader(), SIGNAL(downloadFailure(QString,QString)), SLOT(handleDownloadFailure(QString,QString)));
|
2011-01-27 20:18:56 +03:00
|
|
|
// Download the RSS Feed icon
|
|
|
|
m_iconUrl = iconUrl();
|
2012-02-19 20:53:10 +04:00
|
|
|
manager->rssDownloader()->downloadUrl(m_iconUrl);
|
2011-09-26 21:25:59 +04:00
|
|
|
|
|
|
|
// Load old RSS articles
|
|
|
|
loadItemsFromDisk();
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RssFeed::~RssFeed(){
|
2011-01-27 20:18:56 +03:00
|
|
|
if(!m_icon.startsWith(":/") && QFile::exists(m_icon))
|
2012-02-18 14:49:05 +04:00
|
|
|
QFile::remove(m_icon);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-09-26 21:25:59 +04:00
|
|
|
void RssFeed::saveItemsToDisk() {
|
2012-02-19 22:36:01 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << m_url;
|
|
|
|
if (!m_refreshed)
|
|
|
|
return;
|
2011-09-26 21:25:59 +04:00
|
|
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
|
|
|
QVariantList old_items;
|
2012-02-19 18:38:41 +04:00
|
|
|
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
|
|
|
|
old_items << it.value()->toHash();
|
2011-09-26 21:25:59 +04:00
|
|
|
}
|
|
|
|
qDebug("Saving %d old items for feed %s", old_items.size(), displayName().toLocal8Bit().data());
|
|
|
|
QHash<QString, QVariant> all_old_items = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
|
|
|
|
all_old_items[m_url] = old_items;
|
|
|
|
qBTRSS.setValue("old_items", all_old_items);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RssFeed::loadItemsFromDisk() {
|
|
|
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
|
|
|
QHash<QString, QVariant> all_old_items = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
|
|
|
|
const QVariantList old_items = all_old_items.value(m_url, QVariantList()).toList();
|
|
|
|
qDebug("Loading %d old items for feed %s", old_items.size(), displayName().toLocal8Bit().data());
|
|
|
|
|
2012-02-19 18:38:41 +04:00
|
|
|
foreach (const QVariant &var_it, old_items) {
|
2011-09-26 21:25:59 +04:00
|
|
|
QHash<QString, QVariant> item = var_it.toHash();
|
2012-02-19 18:38:41 +04:00
|
|
|
RssArticlePtr rss_item = hashToRssArticle(this, item);
|
|
|
|
if (rss_item) {
|
|
|
|
m_articles.insert(rss_item->guid(), rss_item);
|
2011-09-26 21:25:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 21:39:03 +04:00
|
|
|
void RssFeed::refresh() {
|
2011-10-05 19:54:06 +04:00
|
|
|
if(m_loading) {
|
|
|
|
qWarning() << Q_FUNC_INFO << "Feed" << this->displayName() << "is already being refreshed, ignoring request";
|
|
|
|
return;
|
|
|
|
}
|
2011-01-27 20:18:56 +03:00
|
|
|
m_loading = true;
|
|
|
|
// Download the RSS again
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->rssDownloader()->downloadUrl(m_url);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RssFeed::removeAllSettings() {
|
2012-02-19 22:36:01 +04:00
|
|
|
qDebug() << "Removing all settings / history for feed: " << m_url;
|
2010-10-16 21:39:03 +04:00
|
|
|
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
|
|
|
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
|
2011-09-26 21:35:50 +04:00
|
|
|
if (feeds_w_downloader.contains(m_url)) {
|
2011-01-27 20:18:56 +03:00
|
|
|
feeds_w_downloader.remove(m_url);
|
2010-10-16 21:39:03 +04:00
|
|
|
qBTRSS.setValue("downloader_on", feeds_w_downloader);
|
|
|
|
}
|
|
|
|
QHash<QString, QVariant> all_feeds_filters = qBTRSS.value("feed_filters", QHash<QString, QVariant>()).toHash();
|
2011-09-26 21:35:50 +04:00
|
|
|
if (all_feeds_filters.contains(m_url)) {
|
2011-01-27 20:18:56 +03:00
|
|
|
all_feeds_filters.remove(m_url);
|
2010-10-16 21:39:03 +04:00
|
|
|
qBTRSS.setValue("feed_filters", all_feeds_filters);
|
|
|
|
}
|
2011-09-26 21:35:50 +04:00
|
|
|
QHash<QString, QVariant> all_old_items = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
|
|
|
|
if (all_old_items.contains(m_url)) {
|
|
|
|
all_old_items.remove(m_url);
|
|
|
|
qBTRSS.setValue("old_items", all_old_items);
|
|
|
|
}
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2012-02-19 17:13:39 +04:00
|
|
|
bool RssFeed::itemAlreadyExists(const QString &guid) const {
|
|
|
|
return m_articles.contains(guid);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RssFeed::setLoading(bool val) {
|
2011-01-27 20:18:56 +03:00
|
|
|
m_loading = val;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
bool RssFeed::isLoading() const {
|
|
|
|
return m_loading;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
QString RssFeed::title() const{
|
|
|
|
return m_title;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 21:03:28 +03:00
|
|
|
void RssFeed::rename(const QString &new_name){
|
2011-01-27 20:18:56 +03:00
|
|
|
qDebug() << "Renaming stream to" << new_name;
|
|
|
|
m_alias = new_name;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the alias if the stream has one, the url if it has no alias
|
2011-01-27 20:18:56 +03:00
|
|
|
QString RssFeed::displayName() const {
|
|
|
|
if(!m_alias.isEmpty()) {
|
2010-10-16 21:39:03 +04:00
|
|
|
//qDebug("getName() returned alias: %s", (const char*)alias.toLocal8Bit());
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_alias;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
2011-01-27 20:18:56 +03:00
|
|
|
if(!m_title.isEmpty()) {
|
2010-10-16 21:39:03 +04:00
|
|
|
//qDebug("getName() returned title: %s", (const char*)title.toLocal8Bit());
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_title;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
//qDebug("getName() returned url: %s", (const char*)url.toLocal8Bit());
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_url;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
QString RssFeed::url() const{
|
|
|
|
return m_url;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
QString RssFeed::icon() const{
|
|
|
|
if(m_downloadFailure)
|
2010-10-16 21:39:03 +04:00
|
|
|
return ":/Icons/oxygen/unavailable.png";
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_icon;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RssFeed::hasCustomIcon() const{
|
2011-01-27 20:18:56 +03:00
|
|
|
return !m_icon.startsWith(":/");
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
void RssFeed::setIconPath(const QString &path) {
|
|
|
|
if(path.isEmpty() || !QFile::exists(path)) return;
|
|
|
|
m_icon = path;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2012-02-19 18:38:41 +04:00
|
|
|
RssArticlePtr RssFeed::getItem(const QString &guid) const {
|
2012-02-19 17:42:51 +04:00
|
|
|
return m_articles.value(guid);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-29 17:10:08 +03:00
|
|
|
uint RssFeed::count() const{
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_articles.size();
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
void RssFeed::markAsRead() {
|
2012-02-19 18:38:41 +04:00
|
|
|
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
|
|
|
|
it.value()->markAsRead();
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2011-01-29 17:10:08 +03:00
|
|
|
uint RssFeed::unreadCount() const{
|
2012-02-19 18:38:41 +04:00
|
|
|
uint nbUnread = 0;
|
|
|
|
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
|
|
|
|
if(!it.value()->isRead())
|
2010-10-16 21:39:03 +04:00
|
|
|
++nbUnread;
|
|
|
|
}
|
|
|
|
return nbUnread;
|
|
|
|
}
|
|
|
|
|
2012-02-20 21:28:11 +04:00
|
|
|
RssArticleList RssFeed::articleList() const{
|
2011-01-27 20:18:56 +03:00
|
|
|
return m_articles.values();
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 21:28:11 +04:00
|
|
|
RssArticleList RssFeed::unreadArticleList() const {
|
2012-02-19 20:53:10 +04:00
|
|
|
RssArticleList unread_news;
|
2012-02-19 18:38:41 +04:00
|
|
|
for (RssArticleHash::ConstIterator it = m_articles.begin(); it != m_articles.end(); it++) {
|
|
|
|
if(!it.value()->isRead())
|
|
|
|
unread_news << it.value();
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
return unread_news;
|
|
|
|
}
|
|
|
|
|
|
|
|
// download the icon from the adress
|
2011-01-27 20:18:56 +03:00
|
|
|
QString RssFeed::iconUrl() const {
|
|
|
|
const QUrl siteUrl(m_url);
|
|
|
|
// XXX: This works for most sites but it is not perfect
|
|
|
|
return QString("http://")+siteUrl.host()+QString("/favicon.ico");
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// read and create items from a rss document
|
2011-01-27 20:18:56 +03:00
|
|
|
bool RssFeed::parseRSS(QIODevice* device) {
|
2010-10-16 21:39:03 +04:00
|
|
|
qDebug("Parsing RSS file...");
|
|
|
|
QXmlStreamReader xml(device);
|
|
|
|
// is it a rss file ?
|
|
|
|
if (xml.atEnd()) {
|
|
|
|
qDebug("ERROR: Could not parse RSS file");
|
2011-01-27 20:18:56 +03:00
|
|
|
return false;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
while (!xml.atEnd()) {
|
|
|
|
xml.readNext();
|
|
|
|
if(xml.isStartElement()) {
|
|
|
|
if(xml.name() != "rss") {
|
|
|
|
qDebug("ERROR: this is not a rss file, root tag is <%s>", qPrintable(xml.name().toString()));
|
2011-01-27 20:18:56 +03:00
|
|
|
return false;
|
2010-10-16 21:39:03 +04:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Read channels
|
|
|
|
while(!xml.atEnd()) {
|
|
|
|
xml.readNext();
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
if(!xml.isStartElement())
|
|
|
|
continue;
|
2010-10-16 21:39:03 +04:00
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
if(xml.name() != "channel")
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Parse channel content
|
|
|
|
while(!xml.atEnd()) {
|
|
|
|
xml.readNext();
|
|
|
|
|
|
|
|
if(xml.isEndElement() && xml.name() == "channel")
|
|
|
|
break; // End of this channel, parse the next one
|
|
|
|
|
|
|
|
if(!xml.isStartElement())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(xml.name() == "title") {
|
|
|
|
m_title = xml.readElementText();
|
|
|
|
if(m_alias == url())
|
2011-01-27 21:03:28 +03:00
|
|
|
rename(m_title);
|
2011-01-27 20:18:56 +03:00
|
|
|
}
|
|
|
|
else if(xml.name() == "image") {
|
|
|
|
QString icon_path = xml.attributes().value("url").toString();
|
|
|
|
if(!icon_path.isEmpty()) {
|
|
|
|
m_iconUrl = icon_path;
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->rssDownloader()->downloadUrl(m_iconUrl);
|
2011-01-27 20:18:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(xml.name() == "item") {
|
2012-02-19 18:38:41 +04:00
|
|
|
RssArticlePtr art = xmlToRssArticle(this, xml);
|
|
|
|
if(art && !itemAlreadyExists(art->guid()))
|
|
|
|
m_articles.insert(art->guid(), art);
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-19 22:36:01 +04:00
|
|
|
// Make sure we limit the number of articles
|
|
|
|
resizeList();
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
// RSS Feed Downloader
|
|
|
|
if(RssSettings().isRssDownloadingEnabled())
|
|
|
|
downloadMatchingArticleTorrents();
|
|
|
|
|
2011-09-26 21:47:10 +04:00
|
|
|
// Save items to disk (for safety)
|
|
|
|
saveItemsToDisk();
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RssFeed::downloadMatchingArticleTorrents() {
|
|
|
|
Q_ASSERT(RssSettings().isRssDownloadingEnabled());
|
2012-02-19 18:38:41 +04:00
|
|
|
for (RssArticleHash::ConstIterator it = m_articles.begin(); it != m_articles.end(); it++) {
|
|
|
|
RssArticlePtr item = it.value();
|
|
|
|
if(item->isRead()) continue;
|
2011-01-27 20:18:56 +03:00
|
|
|
QString torrent_url;
|
2012-02-19 18:38:41 +04:00
|
|
|
if(item->hasAttachment())
|
|
|
|
torrent_url = item->torrentUrl();
|
2011-01-27 20:18:56 +03:00
|
|
|
else
|
2012-02-19 18:38:41 +04:00
|
|
|
torrent_url = item->link();
|
2011-01-27 20:18:56 +03:00
|
|
|
// Check if the item should be automatically downloaded
|
2012-02-19 20:53:10 +04:00
|
|
|
RssDownloadRulePtr matching_rule = RssDownloadRuleList::instance()->findMatchingRule(m_url, item->title());
|
|
|
|
if(matching_rule) {
|
2011-09-26 21:47:10 +04:00
|
|
|
// Item was downloaded, consider it as Read
|
2012-02-19 18:38:41 +04:00
|
|
|
item->markAsRead();
|
2011-01-27 20:18:56 +03:00
|
|
|
// Download the torrent
|
2012-02-19 18:38:41 +04:00
|
|
|
QBtSession::instance()->addConsoleMessage(tr("Automatically downloading %1 torrent from %2 RSS feed...").arg(item->title()).arg(displayName()));
|
2012-02-19 20:53:10 +04:00
|
|
|
QBtSession::instance()->downloadUrlAndSkipDialog(torrent_url, matching_rule->savePath(), matching_rule->label());
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RssFeed::resizeList() {
|
2011-01-27 20:18:56 +03:00
|
|
|
const uint max_articles = RssSettings().getRSSMaxArticlesPerFeed();
|
|
|
|
const uint nb_articles = m_articles.size();
|
2010-10-16 21:39:03 +04:00
|
|
|
if(nb_articles > max_articles) {
|
2012-02-19 20:53:10 +04:00
|
|
|
RssArticleList listItems = m_articles.values();
|
2012-02-19 17:13:39 +04:00
|
|
|
RssManager::sortNewsList(listItems);
|
2011-01-24 20:58:57 +03:00
|
|
|
const int excess = nb_articles - max_articles;
|
2011-01-25 21:46:38 +03:00
|
|
|
for(uint i=nb_articles-excess; i<nb_articles; ++i){
|
2012-02-19 18:38:41 +04:00
|
|
|
m_articles.remove(listItems.at(i)->guid());
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// existing and opening test after download
|
2011-01-27 20:18:56 +03:00
|
|
|
bool RssFeed::parseXmlFile(const QString &file_path){
|
2010-10-16 21:39:03 +04:00
|
|
|
qDebug("openRss() called");
|
2011-01-27 20:18:56 +03:00
|
|
|
QFile fileRss(file_path);
|
2010-10-16 21:39:03 +04:00
|
|
|
if(!fileRss.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
2011-01-27 20:18:56 +03:00
|
|
|
qDebug("openRss error: open failed, no file or locked, %s", qPrintable(file_path));
|
|
|
|
if(QFile::exists(file_path)) {
|
2010-10-16 21:39:03 +04:00
|
|
|
fileRss.remove();
|
|
|
|
}
|
2011-01-27 20:18:56 +03:00
|
|
|
return false;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// start reading the xml
|
2011-01-27 20:18:56 +03:00
|
|
|
bool ret = parseRSS(&fileRss);
|
2010-10-16 21:39:03 +04:00
|
|
|
fileRss.close();
|
2011-01-27 20:18:56 +03:00
|
|
|
if(QFile::exists(file_path))
|
2010-10-16 21:39:03 +04:00
|
|
|
fileRss.remove();
|
2011-01-27 20:18:56 +03:00
|
|
|
return ret;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// read and store the downloaded rss' informations
|
2011-01-27 20:18:56 +03:00
|
|
|
void RssFeed::handleFinishedDownload(const QString& url, const QString &file_path) {
|
|
|
|
if(url == m_url) {
|
2011-10-05 19:54:06 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << "Successfuly downloaded RSS feed at" << url;
|
2011-01-27 20:18:56 +03:00
|
|
|
m_downloadFailure = false;
|
|
|
|
m_loading = false;
|
|
|
|
// Parse the download RSS
|
|
|
|
if(parseXmlFile(file_path)) {
|
|
|
|
m_refreshed = true;
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->forwardFeedInfosChanged(m_url, displayName(), unreadCount()); // XXX: Ugly
|
2011-10-05 19:54:06 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << "Feed parsed successfuly";
|
2011-01-27 20:18:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(url == m_iconUrl) {
|
|
|
|
m_icon = file_path;
|
2011-10-05 19:54:06 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << "icon path:" << m_icon;
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->forwardFeedIconChanged(m_url, m_icon); // XXX: Ugly
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-27 20:18:56 +03:00
|
|
|
void RssFeed::handleDownloadFailure(const QString &url, const QString& error) {
|
|
|
|
if(url != m_url) return;
|
|
|
|
m_downloadFailure = true;
|
|
|
|
m_loading = false;
|
2012-02-19 20:53:10 +04:00
|
|
|
m_manager->forwardFeedInfosChanged(m_url, displayName(), unreadCount()); // XXX: Ugly
|
2011-10-05 19:54:06 +04:00
|
|
|
qWarning() << "Failed to download RSS feed at" << url;
|
|
|
|
qWarning() << "Reason:" << error;
|
2010-10-16 21:39:03 +04:00
|
|
|
}
|