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(); }
RSSFeedPlugin::RSSFeedPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID), ui(new Ui::RSSFeedPlugin()){ ui->setupUi(this); //Load the global settings setprefix = "rssreader/"; //this structure/prefix should be used for *all* plugins of this type RSS = new RSSReader(this, setprefix); //Create the options menu optionsMenu = new QMenu(this); ui->tool_options->setMenu(optionsMenu); presetMenu = new QMenu(this); ui->tool_add_preset->setMenu(presetMenu); //Setup any signal/slot connections connect(ui->push_back1, SIGNAL(clicked()), this, SLOT(backToFeeds()) ); connect(ui->push_back2, SIGNAL(clicked()), this, SLOT(backToFeeds()) ); connect(ui->push_back3, SIGNAL(clicked()), this, SLOT(backToFeeds()) ); connect(ui->push_save_settings, SIGNAL(clicked()), this, SLOT(saveSettings()) ); connect(RSS, SIGNAL(rssChanged(QString)), this, SLOT(RSSItemChanged(QString)) ); connect(RSS, SIGNAL(newChannelsAvailable()), this, SLOT(UpdateFeedList())); connect(ui->tool_gotosite, SIGNAL(clicked()), this, SLOT(openFeedPage()) ); connect(ui->push_rm_feed, SIGNAL(clicked()), this, SLOT(removeFeed()) ); connect(ui->push_add_url, SIGNAL(clicked()), this, SLOT(addNewFeed()) ); connect(ui->combo_feed, SIGNAL(currentIndexChanged(int)), this, SLOT(currentFeedChanged()) ); connect(presetMenu, SIGNAL(triggered(QAction*)), this, SLOT(loadPreset(QAction*)) ); updateOptionsMenu(); QTimer::singleShot(0,this, SLOT(ThemeChange()) ); //qDebug() << " - Done with init"; QStringList feeds; if( !LSession::handle()->DesktopPluginSettings()->contains(setprefix+"currentfeeds") ){ //First-time run of the plugin - automatically load the default feeds feeds = LOS::RSSFeeds(); for(int i=0; i<feeds.length(); i++){ feeds[i] = feeds[i].section("::::",1,-1); } //just need url right now feeds << "http://lumina-desktop.org/?feed=rss2"; //Lumina Desktop blog feed LSession::handle()->DesktopPluginSettings()->setValue(setprefix+"currentfeeds", feeds); }else{ feeds = LSession::handle()->DesktopPluginSettings()->value(setprefix+"currentfeeds",QStringList()).toStringList(); } RSS->addUrls(feeds); backToFeeds(); //always load the first page }