void RSSManager::load(SimpleXML& aXml) { { CFlyLock(g_csFeed); aXml.resetCurrentChild(); if (aXml.findChild("Rss")) { aXml.stepIn(); while (aXml.findChild("Feed")) { const string& realURL = aXml.getChildData(); if (realURL.empty()) { continue; } const string& sourceName = aXml.getChildAttrib("Name"); const string& codeingType = aXml.getChildAttrib("Codeing"); const size_t iCodeingType = Util::toInt(codeingType); // add only unique RSS feeds addNewFeed(realURL, sourceName, getCodeing(iCodeingType)); } aXml.stepOut(); } } updateFeeds(); }
void RSSManager::on(TimerManagerListener::Minute, uint64_t tick) noexcept { if (SETTING(RSS_AUTO_REFRESH_TIME) > 0) { if (++m_minuteCounter >= (unsigned int) SETTING(RSS_AUTO_REFRESH_TIME)) { updateFeeds(); // [!] IRainman fix done [2] https://www.box.net/shared/be613d6f54c533c0e1ff m_minuteCounter = 0; } } }
RSSFeed* RSSManager::addNewFeed(const string& url, const string& name, const string& codeing, bool bUpdateFeeds/* = false */) { CFlyLock(g_csFeed); // [+] IRainman fix. if (!hasRSSFeed(url, name)) { RSSFeed* rFeed = new RSSFeed(url, name, codeing); g_feeds.push_back(rFeed); if (bUpdateFeeds) { updateFeeds(); } return rFeed; } return nullptr; }
bool Core::DoDelayedInit () { QDir dir = QDir::home (); if (!dir.cd (".leechcraft/aggregator") && !dir.mkpath (".leechcraft/aggregator")) { qCritical () << Q_FUNC_INFO << "could not create necessary " "directories for Aggregator"; return false; } ChannelsModel_ = new ChannelsModel (); if (!ReinitStorage ()) return false; PluginManager_->RegisterHookable (StorageBackend_.get ()); ChannelsFilterModel_ = new ChannelsFilterModel (); ChannelsFilterModel_->setSourceModel (ChannelsModel_); ChannelsFilterModel_->setFilterKeyColumn (0); JobHolderRepresentation_ = new JobHolderRepresentation (); connect (DBUpThread_, SIGNAL (started ()), this, SLOT (handleDBUpThreadStarted ()), Qt::QueuedConnection); DBUpThread_->start (QThread::LowestPriority); connect (StorageBackend_.get (), SIGNAL (channelDataUpdated (Channel_ptr)), this, SLOT (handleChannelDataUpdated (Channel_ptr)), Qt::QueuedConnection); connect (StorageBackend_.get (), SIGNAL (itemDataUpdated (Item_ptr, Channel_ptr)), this, SIGNAL (itemDataUpdated (Item_ptr, Channel_ptr))); ParserFactory::Instance ().Register (&RSS20Parser::Instance ()); ParserFactory::Instance ().Register (&Atom10Parser::Instance ()); ParserFactory::Instance ().Register (&RSS091Parser::Instance ()); ParserFactory::Instance ().Register (&Atom03Parser::Instance ()); ParserFactory::Instance ().Register (&RSS10Parser::Instance ()); connect (ChannelsModel_, SIGNAL (channelDataUpdated ()), this, SIGNAL (channelDataUpdated ())); ReprWidget_ = new ItemsWidget (); ReprWidget_->SetChannelsFilter (JobHolderRepresentation_); ChannelsModel_->SetWidgets (ReprWidget_->GetToolBar (), ReprWidget_); JobHolderRepresentation_->setSourceModel (ChannelsModel_); CustomUpdateTimer_ = new QTimer (this); CustomUpdateTimer_->start (60 * 1000); connect (CustomUpdateTimer_, SIGNAL (timeout ()), this, SLOT (handleCustomUpdates ())); UpdateTimer_ = new QTimer (this); UpdateTimer_->setSingleShot (true); QDateTime currentDateTime = QDateTime::currentDateTime (); QDateTime lastUpdated = XmlSettingsManager::Instance ()-> Property ("LastUpdateDateTime", currentDateTime).toDateTime (); connect (UpdateTimer_, SIGNAL (timeout ()), this, SLOT (updateFeeds ())); int updateDiff = lastUpdated.secsTo (currentDateTime); int interval = XmlSettingsManager::Instance ()-> property ("UpdateInterval").toInt (); if (interval) { if ((XmlSettingsManager::Instance ()-> property ("UpdateOnStartup").toBool ()) || (updateDiff > interval * 60)) QTimer::singleShot (7000, this, SLOT (updateFeeds ())); else UpdateTimer_->start (updateDiff * 1000); } QTimer *saveTimer = new QTimer (this); saveTimer->start (60 * 1000); connect (saveTimer, SIGNAL (timeout ()), this, SLOT (scheduleSave ())); XmlSettingsManager::Instance ()-> RegisterObject ("UpdateInterval", this, "updateIntervalChanged"); XmlSettingsManager::Instance ()-> RegisterObject ("ShowIconInTray", this, "showIconInTrayChanged"); UpdateUnreadItemsNumber (); Initialized_ = true; return true; }
bool Core::DoDelayedInit () { bool result = true; ShortcutMgr_ = new Util::ShortcutManager (Proxy_, this); QDir dir = QDir::home (); if (!dir.cd (".leechcraft/aggregator") && !dir.mkpath (".leechcraft/aggregator")) { qCritical () << Q_FUNC_INFO << "could not create necessary " "directories for Aggregator"; result = false; } ChannelsModel_ = new ChannelsModel (); if (!ReinitStorage ()) result = false; ChannelsFilterModel_ = new ChannelsFilterModel (); ChannelsFilterModel_->setSourceModel (ChannelsModel_); ChannelsFilterModel_->setFilterKeyColumn (0); JobHolderRepresentation_ = new JobHolderRepresentation (); DBUpThread_ = std::make_shared<DBUpdateThread> (Proxy_); DBUpThread_->start (QThread::LowestPriority); DBUpThread_->ScheduleImpl (&DBUpdateThreadWorker::WithWorker, [this] (DBUpdateThreadWorker *worker) { connect (worker, SIGNAL (gotNewChannel (ChannelShort)), this, SLOT (handleDBUpGotNewChannel (ChannelShort)), Qt::QueuedConnection); connect (worker, SIGNAL (hookGotNewItems (LeechCraft::IHookProxy_ptr, QList<Item_cptr>)), this, SIGNAL (hookGotNewItems (LeechCraft::IHookProxy_ptr, QList<Item_cptr>))); }); connect (&StorageBackendManager::Instance (), SIGNAL (channelDataUpdated (Channel_ptr)), this, SLOT (handleChannelDataUpdated (Channel_ptr)), Qt::QueuedConnection); ParserFactory::Instance ().Register (&RSS20Parser::Instance ()); ParserFactory::Instance ().Register (&Atom10Parser::Instance ()); ParserFactory::Instance ().Register (&RSS091Parser::Instance ()); ParserFactory::Instance ().Register (&Atom03Parser::Instance ()); ParserFactory::Instance ().Register (&RSS10Parser::Instance ()); ReprWidget_ = new ItemsWidget (); ReprWidget_->SetChannelsFilter (JobHolderRepresentation_); ReprWidget_->RegisterShortcuts (); ChannelsModel_->SetWidgets (ReprWidget_->GetToolBar (), ReprWidget_); JobHolderRepresentation_->setSourceModel (ChannelsModel_); CustomUpdateTimer_ = new QTimer (this); CustomUpdateTimer_->start (60 * 1000); connect (CustomUpdateTimer_, SIGNAL (timeout ()), this, SLOT (handleCustomUpdates ())); UpdateTimer_ = new QTimer (this); UpdateTimer_->setSingleShot (true); QDateTime currentDateTime = QDateTime::currentDateTime (); QDateTime lastUpdated = XmlSettingsManager::Instance ()-> Property ("LastUpdateDateTime", currentDateTime).toDateTime (); connect (UpdateTimer_, SIGNAL (timeout ()), this, SLOT (updateFeeds ())); int updateDiff = lastUpdated.secsTo (currentDateTime); int interval = XmlSettingsManager::Instance ()-> property ("UpdateInterval").toInt (); if (interval) { if ((XmlSettingsManager::Instance ()-> property ("UpdateOnStartup").toBool ()) || (updateDiff > interval * 60)) QTimer::singleShot (7000, this, SLOT (updateFeeds ())); else UpdateTimer_->start (updateDiff * 1000); } XmlSettingsManager::Instance ()-> RegisterObject ("UpdateInterval", this, "updateIntervalChanged"); Initialized_ = true; PluginManager_ = new PluginManager (); PluginManager_->RegisterHookable (this); PluginManager_->RegisterHookable (StorageBackend_.get ()); return result; }