Example #1
0
void RssParser::parseAtomChannel(QXmlStreamReader& xml, const QString& feedUrl)
{
  qDebug() << Q_FUNC_INFO << feedUrl;
  Q_ASSERT(xml.isStartElement() && xml.name() == "feed");

  QString baseURL = xml.attributes().value("xml:base").toString();

  while(!xml.atEnd()) {
    xml.readNext();

    if (xml.isStartElement()) {
      if (xml.name() == "title") {
        QString title = xml.readElementText();
        emit feedTitle(feedUrl, title);
      }
      else if (xml.name() == "updated") {
        QString lastBuildDate = xml.readElementText();
        if (!lastBuildDate.isEmpty()) {
          QMutexLocker locker(&m_mutex);
          if (m_lastBuildDates.value(feedUrl) == lastBuildDate) {
            qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
            return;
          }
          m_lastBuildDates[feedUrl] = lastBuildDate;
        }
      }
      else if (xml.name() == "entry") {
        parseAtomArticle(xml, feedUrl, baseURL);
      }
    }
  }
}
Example #2
0
RssFeed::RssFeed(RssManager* manager, RssFolder* parent, const QString& url):
  m_manager(manager),
  m_parent(parent),
  m_url (QUrl::fromEncoded(url.toUtf8()).toString()),
  m_icon(":/Icons/oxygen/application-rss+xml.png"),
  m_unreadCount(0),
  m_dirty(false),
  m_inErrorState(false),
  m_loading(false)
{
  qDebug() << Q_FUNC_INFO << m_url;
  // Listen for new RSS downloads
  connect(manager->rssDownloader(), SIGNAL(downloadFinished(QString,QString)), SLOT(handleFinishedDownload(QString,QString)));
  connect(manager->rssDownloader(), SIGNAL(downloadFailure(QString,QString)), SLOT(handleDownloadFailure(QString,QString)));
  connect(manager->rssParser(), SIGNAL(feedTitle(QString,QString)), SLOT(handleFeedTitle(QString,QString)));
  connect(manager->rssParser(), SIGNAL(newArticle(QString,QVariantHash)), SLOT(handleNewArticle(QString,QVariantHash)));
  connect(manager->rssParser(), SIGNAL(feedParsingFinished(QString,QString)), SLOT(handleFeedParsingFinished(QString,QString)));

  // Download the RSS Feed icon
  m_iconUrl = iconUrl();
  manager->rssDownloader()->downloadUrl(m_iconUrl);

  // Load old RSS articles
  loadItemsFromDisk();
}
Example #3
0
FeedListWidget::FeedListWidget(BirdBox *b,ImageCache *i, QWidget *parent) : TweetListWidget(b,i,parent) {
	QObject::connect(ui.topCloseButton,SIGNAL(clicked()),this,SLOT(showFeed()));
	QObject::connect(ui.title,SIGNAL(doubleclicked()),this,SLOT(showTopText()));
	QObject::connect(&feed,SIGNAL(feedTitle(QString)),this,SLOT(handleFeedTitle(QString)));
//	QObject::connect(&feed,SIGNAL(haveResults(QList<QString>)),this,SLOT(searchUpdate(QList<QString>)));
//	QObject::connect(&searcher,SIGNAL(endFetching()),this,SLOT(handleEndFetching()));
//	QObject::connect(ui.closeButton,SIGNAL(clicked()),this,SLOT(close()));
	b->addFetcher(&feed);
	ui.title->setToolTip("Double click to change the feed.");
	ui.title->setObjectName("feed");
	ui.title->setText("Feed");
	ui.type->setPixmap(QPixmap(":/buttons/feed.png"));
	ui.topCloseButton->setIcon(QIcon(":/buttons/feed.png"));
	showTopText();
//	defaultTitleStyle="color: green;";
	type=8;
}
Example #4
0
void FeedFetcher::handleRdfXml(QDomNode node) {
	QList<Tweet*> tweets;
	QDomNodeList children = node.childNodes();
	QDateTime startDate = QDateTime::currentDateTime();
	for (int x=0;x<children.count();x++) {
		QDomNode item = children.at(x);
//			QMessageBox::information(0,"Bleugh",item.nodeName());
		if (nodeName(item)=="channel") {
			QDomNode title = item.firstChildElement("title");
			if (!title.isNull())
				emit feedTitle(title.firstChild().nodeValue());
		} else if (nodeName(item)=="item") {
			FeedItem *tweet = new FeedItem();
			tweet->created_at=startDate.addSecs(-x);
			tweet->feed_item_date="";//tweet->created_at.toString();
			tweet->sourceUrl=url;
			QDomNodeList children2 = item.childNodes();
			for (int y=0;y<children2.count();y++) {
				QDomNode childItem = children2.at(y);
				if (nodeName(childItem)=="title") {
					tweet->message=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="guid") {
					tweet->id=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="description") {
					tweet->content=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="link") {
					tweet->url=childItem.firstChild().nodeValue();
					if (tweet->id=="")
						tweet->id=tweet->url;
				} else if (nodeName(childItem)=="pubDate") {
					//Thu Feb 19 00:20:20 +0000 2009
					QString date = childItem.firstChild().nodeValue();
//					tweet->feed_item_date = childItem.firstChild().nodeValue().left(26);
//						QString hour = dateStr.mid(20,5);
//						dateStr=dateStr.left(20)+dateStr.right(4);
//					tweet->created_at=QDateTime::fromString(dateStr,"ddd MMM dd HH:mm:ss +0000 yyyy");
					// Sat, 05 Sep 2009 14:51:00 GMT
					tweet->created_at=parseRdfDate(date.left(25));
				}
			}
			tweets.append(tweet);
		}
	}
	emit haveTweets(tweets);
}
Example #5
0
void FeedFetcher::handleAtomXml(QDomNode node) {
	QList<Tweet*> tweets;
	QDomNodeList children = node.childNodes();
	QDateTime startDate = QDateTime::currentDateTime();
//	QMessageBox::information(0,"Bleugh",nodeName(node));
	for (int x=0;x<children.count();x++) {
		QDomNode item = children.at(x);
//			QMessageBox::information(0,"Bleugh",item.nodeName());
		if (nodeName(item)=="title") {
			emit feedTitle(item.firstChild().nodeValue());
		} else if (nodeName(item)=="entry") {
			FeedItem *tweet = new FeedItem();
			tweet->created_at=startDate.addSecs(-x);
			tweet->feed_item_date="";//tweet->created_at.toString();
			tweet->sourceUrl=url;
			QDomNodeList children2 = item.childNodes();
			for (int y=0;y<children2.count();y++) {
				QDomNode childItem = children2.at(y);
				if (nodeName(childItem)=="title") {
					tweet->message=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="id") {
					tweet->id=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="summary") {
					tweet->content=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="link") {
					tweet->url=childItem.attributes().namedItem("href").nodeValue();
					if (tweet->id=="")
						tweet->id=tweet->url;
				} else if (nodeName(childItem)=="updated") {
					//Thu Feb 19 00:20:20 +0000 2009
					QString date = childItem.firstChild().nodeValue();
					//					tweet->feed_item_date = childItem.firstChild().nodeValue();
//						QString hour = dateStr.mid(20,5);
//						dateStr=dateStr.left(20)+dateStr.right(4);
//					tweet->created_at=QDateTime::fromString(dateStr,"ddd MMM dd HH:mm:ss +0000 yyyy");
					// 2009-09-04T22:29:51Z
					tweet->created_at=QDateTime::fromString(date.left(19),"yyyy-MM-ddTHH:mm:ss");
				}
			}
			tweets.append(tweet);
		}
	}
	emit haveTweets(tweets);
}