diff options
author | louis <louis.braun@gmx.de> | 2013-04-08 19:04:24 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-04-08 19:04:24 +0200 |
commit | e269a87fc24964fbaac485d6a60f3c331ed321a6 (patch) | |
tree | 0beb182ba45c484fbd7da378b460041b32987721 /rssreader.c | |
parent | 7e65ecacd2a1caba224eed98c81870f2a943a479 (diff) | |
download | skin-nopacity-e269a87fc24964fbaac485d6a60f3c331ed321a6.tar.gz skin-nopacity-e269a87fc24964fbaac485d6a60f3c331ed321a6.tar.bz2 |
Added standalone RSS Feed
Diffstat (limited to 'rssreader.c')
-rw-r--r-- | rssreader.c | 105 |
1 files changed, 104 insertions, 1 deletions
diff --git a/rssreader.c b/rssreader.c index d3ff151..ae9eef1 100644 --- a/rssreader.c +++ b/rssreader.c @@ -170,6 +170,7 @@ void cRssReader::DoSleep(int duration) { } void cRssReader::Action(void) { +esyslog("nopacity: feed %s", feedUrl.c_str()); int success = readRssURL(feedUrl.c_str()); if (success < 1) return; @@ -181,7 +182,7 @@ void cRssReader::Action(void) { return; } saveRss(); - +//debugRSS(); int numElements = rssElements.size(); int scrollDelay = config.rssScrollDelay * 1000; int drawPortX; @@ -252,3 +253,105 @@ void cRssReader::fadeInOut(bool fadeIn) { DoSleep(frameTime); } } + +void cRssReader::debugRSS(void) { + for (std::vector<RssElement>::iterator it = rssElements.begin(); it!=rssElements.end(); ++it) { + esyslog("nopacity: title %s", it->title.c_str()); + esyslog("nopacity: content %s", it->content.c_str()); + } + +} + +cRssStandaloneTicker::cRssStandaloneTicker(void) { + osdLeft = cOsd::OsdLeft(); + osdWidth = cOsd::OsdWidth(); + osdHeight = config.rssFeedHeightStandalone * cOsd::OsdHeight() / 100; + if (config.rssFeedStandalonePos == 0) + osdTop = cOsd::OsdHeight() - osdHeight - 5; + else + osdTop = cOsd::OsdTop() + 5; + + osd = CreateOsd(osdLeft, osdTop, osdWidth, osdHeight); + font = cFont::CreateFont(config.fontName, (osdHeight / 2) + 3 + config.fontRssFeedStandalone); + pixmapBackground = osd->CreatePixmap(1, cRect(0, 0, osdWidth, osdHeight)); + pixmapFeed = osd->CreatePixmap(2, cRect(0, 0, osdWidth, osdHeight)); + pixmapIcon = osd->CreatePixmap(3, cRect(0, 0, osdHeight, osdHeight)); + currentFeed = 0; +} + +cRssStandaloneTicker::~cRssStandaloneTicker() { + if (rssReader) { + rssReader->Stop(); + while (rssReader->Active()) + cCondWait::SleepMs(10); + delete rssReader; + rssReader = NULL; + } + osd->DestroyPixmap(pixmapFeed); + osd->DestroyPixmap(pixmapBackground); + osd->DestroyPixmap(pixmapIcon); + delete font; + delete osd; +} + +void cRssStandaloneTicker::SetFeed(std::string feedName) { + pixmapBackground->Fill(clrBlack); + pixmapFeed->Fill(clrTransparent); + pixmapIcon->Fill(clrTransparent); + + int feedNameLength = font->Width(feedName.c_str()); + labelWidth = 2 + osdHeight + 2 + feedNameLength + 6; + pixmapFeed->Fill(Theme.Color(clrMenuBorder)); + cImageLoader imgLoader; + imgLoader.DrawBackground(Theme.Color(clrMenuItemHigh), Theme.Color(clrMenuItemHighBlend), labelWidth, osdHeight - 4); + pixmapFeed->DrawImage(cPoint(2,2), imgLoader.GetImage()); + + imgLoader.DrawBackground(Theme.Color(clrMenuItem), Theme.Color(clrMenuItemBlend), osdWidth - labelWidth - 2, osdHeight - 4); + pixmapFeed->DrawImage(cPoint(labelWidth,2), imgLoader.GetImage()); + + pixmapFeed->DrawText(cPoint(osdHeight + 2, (osdHeight - font->Height()) / 2), feedName.c_str(), Theme.Color(clrMenuFontHeader), clrTransparent, font); + pixmapIcon->Fill(clrTransparent); + if (imgLoader.LoadIcon("skinIcons/rss", osdHeight-4)) { + cImage icon = imgLoader.GetImage(); + pixmapIcon->DrawImage(cPoint(2,2), icon); + } + + osd->Flush(); +} + +void cRssStandaloneTicker::Start(void) { + rssReader = new cRssReader(osd, font, cPoint(labelWidth,0), cPoint(osdWidth, osdHeight)); + rssReader->SetFeed(config.rssFeeds[config.rssFeed[currentFeed]].url); + rssReader->Start(); +} + +void cRssStandaloneTicker::SwitchNextRssMessage(void) { + if (rssReader) { + rssReader->SwitchNextMessage(); + } +} + +void cRssStandaloneTicker::SwitchNextRssFeed(void) { + if (rssReader) { + rssReader->Stop(); + while (rssReader->Active()) + cCondWait::SleepMs(10); + delete rssReader; + rssReader = NULL; + } + SetNextFeed(); + int feedNum = (config.rssFeed[currentFeed]==0)?0:(config.rssFeed[currentFeed]-1); + SetFeed(config.rssFeeds[feedNum].name); + Start(); +} + +void cRssStandaloneTicker::SetNextFeed(void) { + int nextFeed = 0; + for (int i = 1; i<6; i++) { + nextFeed = (currentFeed + i)%5; + if ((nextFeed == 0)||(config.rssFeed[nextFeed] > 0)) { + currentFeed = nextFeed; + break; + } + } +}
\ No newline at end of file |