Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 463 lines (395 sloc) 11.597 kb
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
1 // RssReader.cpp: implementation of the CRssReader class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
ddd8ee0 Merged with main trunk up to revision 8787
yuvalt authored
5 #include "stdafx.h"
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
6 #include "RssReader.h"
011dc86 Initial port to Linux/SDL
yuvalt authored
7 #include "HTTP.h"
eadc897 rss feeds now handle special html characters
jwnmulder authored
8 #include "../utils/HTMLUtil.h"
011dc86 Initial port to Linux/SDL
yuvalt authored
9 #include "../Util.h"
63a8e43 fixed: rewrote network support. Very lightly tested so far, lacks XBOX
yuvalt authored
10 #include "../utils/Network.h"
9e88262 fixed: make ApplicationMessenger and Network members of CApplication
yuvalt authored
11 #include "Application.h"
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
12
6f8eae4 fixed: severe global namespace pollution
spiff_ authored
13 using namespace XFILE;
14
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
15 //////////////////////////////////////////////////////////////////////
16 // Construction/Destruction
17 //////////////////////////////////////////////////////////////////////
18
19 CRssReader::CRssReader() : CThread()
20 {
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
21 m_pObserver = NULL;
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
22 m_spacesBetweenFeeds = 0;
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
23 m_bIsRunning = false;
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
24 m_iconv = (iconv_t) -1;
25 m_shouldFlip = false;
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
26 }
27
28 CRssReader::~CRssReader()
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
29 {
30 if (m_bIsRunning)
31 {
32 StopThread();
33 m_bIsRunning = false;
34 }
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
35 for (unsigned int i = 0; i < m_vecTimeStamps.size(); i++)
36 delete m_vecTimeStamps[i];
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
37 }
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
38
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
39 void CRssReader::Create(IRssObserver* aObserver, const vector<string>& aUrls, const vector<int> &times, int spacesBetweenFeeds)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
40 {
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
41 m_pObserver = aObserver;
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
42 m_spacesBetweenFeeds = spacesBetweenFeeds;
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
43 m_vecUrls = aUrls;
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
44 m_strFeed.resize(aUrls.size());
45 m_strColors.resize(aUrls.size());
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
46 // set update times
47 m_vecUpdateTimes = times;
48 // update each feed on creation
49 for (unsigned int i=0;i<m_vecUpdateTimes.size();++i )
50 {
51 AddToQueue(i);
52 SYSTEMTIME* time = new SYSTEMTIME;
53 GetLocalTime(time);
54 m_vecTimeStamps.push_back(time);
55 }
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
56 }
57
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
58 void CRssReader::AddToQueue(int iAdd)
219ab41 changed: introducing userdata/sources.xml. this is xboxmediacenter.xml w...
spiff_ authored
59 {
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
60 if (iAdd < (int)m_vecUrls.size())
61 m_vecQueue.push_back(iAdd);
62 if (!m_bIsRunning)
63 {
64 StopThread();
219ab41 changed: introducing userdata/sources.xml. this is xboxmediacenter.xml w...
spiff_ authored
65 m_bIsRunning = true;
6c9f25c changed: make some of the default background threads use a smaller stack...
elupus authored
66 CThread::Create(false, THREAD_MINSTACKSIZE);
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
67 }
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
68 }
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
69
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
70 void CRssReader::OnExit()
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
71 {
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
72 m_bIsRunning = false;
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
73 }
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
74
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
75 void CRssReader::Process()
76 {
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
77 while (m_vecQueue.size())
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
78 {
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
79 int iFeed = m_vecQueue.front();
80 m_vecQueue.erase(m_vecQueue.begin());
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
81
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
82 m_strFeed[iFeed] = "";
83 m_strColors[iFeed] = "";
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
84
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
85 CHTTP http;
8274f52 changed: versionstrings from 2.0.1 to pre-2.1
pike2k authored
86 http.SetUserAgent("XBMC/pre-2.1 (http://www.xboxmediacenter.com)");
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
87 CStdString strXML;
88 CStdString strUrl = m_vecUrls[iFeed];
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
89
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
90 int nRetries = 3;
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
91 CURL url(strUrl);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
92
9e88262 fixed: make ApplicationMessenger and Network members of CApplication
yuvalt authored
93 if ((url.GetProtocol() == "http" || url.GetProtocol() == "https") && (!g_guiSettings.GetBool("network.enableinternet") || !g_application.getNetwork().IsAvailable()))
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
94 strXML = "<rss><item><title>"+g_localizeStrings.Get(15301)+"</title></item></rss>";
95 else
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
96 {
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
97 while ( (!m_bStop) && (nRetries > 0) )
8b8095c added: rss reader now supports non-http sources (local/smb/ccx etc).
spiff_ authored
98 {
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
99 nRetries--;
100
0263f9f merge with trunk. revisions: 10222-10278 (not including music video supp...
vulkanr authored
101 if (url.GetProtocol() != "http" && url.GetProtocol() != "https")
8b8095c added: rss reader now supports non-http sources (local/smb/ccx etc).
spiff_ authored
102 {
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
103 CFile file;
104 if (file.Open(strUrl))
105 {
106 char *yo = new char[(int)file.GetLength()+1];
107 file.Read(yo,file.GetLength());
108 yo[file.GetLength()] = '\0';
109 strXML = yo;
110 delete[] yo;
111 break;
112 }
8b8095c added: rss reader now supports non-http sources (local/smb/ccx etc).
spiff_ authored
113 }
4f5bad1 merged: trunk revisions 9502 -> 9635
jmarshallnz authored
114 else
115 if (http.Get(strUrl, strXML))
116 {
117 CLog::Log(LOGDEBUG, "Got rss feed: %s", strUrl.c_str());
118 break;
119 }
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
120 }
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
121 }
122 if ((!strXML.IsEmpty()) && m_pObserver)
123 {
f1c5545 - 19-07-2005 fixed: UTF16 RSS feeds should at least display (no idea if...
jmarshallnz authored
124 // erase any <content:encoded> tags (also unsupported by tinyxml)
51b4509 changed: since tinyxml "now" supports cdata tags, remove the old hack th...
spiff_ authored
125 int iStart = strXML.Find("<content:encoded>");
126 int iEnd = 0;
f1c5545 - 19-07-2005 fixed: UTF16 RSS feeds should at least display (no idea if...
jmarshallnz authored
127 while (iStart > 0)
128 {
129 // get <content:encoded> end position
130 iEnd = strXML.Find("</content:encoded>", iStart) + 18;
131
132 // erase the section
133 strXML = strXML.erase(iStart, iEnd - iStart);
134
135 iStart = strXML.Find("<content:encoded>");
136 }
137
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
138 if (Parse((LPSTR)strXML.c_str(),iFeed))
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
139 {
140 CLog::Log(LOGDEBUG, "Parsed rss feed: %s", strUrl.c_str());
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
141 }
142 }
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
143 }
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
144 UpdateObserver();
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
145 }
146
5e3f789 merge with trunk. revision 10882.
vulkanr authored
147 void CRssReader::getFeed(vector<DWORD> &text)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
148 {
5e3f789 merge with trunk. revision 10882.
vulkanr authored
149 text.clear();
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
150 // double the spaces at the start of the set
5e3f789 merge with trunk. revision 10882.
vulkanr authored
151 for (int j = 0; j < m_spacesBetweenFeeds; j++)
152 text.push_back(L' ');
153 for (unsigned int i = 0; i < m_strFeed.size(); i++)
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
154 {
5e3f789 merge with trunk. revision 10882.
vulkanr authored
155 for (int j = 0; j < m_spacesBetweenFeeds; j++)
156 text.push_back(L' ');
157 for (unsigned int j = 0; j < m_strFeed[i].size(); j++)
158 {
159 DWORD letter = m_strFeed[i][j] | ((m_strColors[i][j] - 48) << 16);
160 text.push_back(letter);
161 }
9c53300 merge with trunk. rev: 9636-10031.
vulkanr authored
162 }
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
163 }
164
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
165 void CRssReader::AddTag(const CStdString aString)
0d4e1ac - 07-09-2004 added: SF patch 1020481: Allow XML configuration of displ...
jmarshallnz authored
166 {
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
167 m_tagSet.push_back(aString);
0d4e1ac - 07-09-2004 added: SF patch 1020481: Allow XML configuration of displ...
jmarshallnz authored
168 }
169
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
170 void CRssReader::AddString(CStdStringW aString, int aColour, int iFeed)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
171 {
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
172 m_strFeed[iFeed] += aString;
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
173
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
174 int nStringLength = aString.GetLength();
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
175
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
176 for (int i = 0;i < nStringLength;i++)
177 {
178 aString[i] = (CHAR) (48 + aColour);
179 }
180
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
181 m_strColors[iFeed] += aString;
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
182 }
183
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
184 void CRssReader::GetNewsItems(TiXmlElement* channelXmlNode, int iFeed)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
185 {
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
186 HTML::CHTMLUtil html;
187
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
188 TiXmlElement * itemNode = channelXmlNode->FirstChildElement("item");
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
189 map <CStdString, CStdStringW> mTagElements;
190 typedef pair <CStdString, CStdStringW> StrPair;
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
191 list <CStdString>::iterator i;
192
b69e8ba - 06-05-2005 added: SF patch [1196172] remove trailing dash for rss-fe...
jmarshallnz authored
193 bool bEmpty=true;
194
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
195 // Add the title tag in if we didn't pass any tags in at all
196 // Represents default behaviour before configurability
197
198 if (m_tagSet.empty())
199 AddTag("title");
200
201 while (itemNode > 0)
202 {
b69e8ba - 06-05-2005 added: SF patch [1196172] remove trailing dash for rss-fe...
jmarshallnz authored
203 bEmpty = false;
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
204 TiXmlNode* childNode = itemNode->FirstChild();
205 mTagElements.clear();
206 while (childNode > 0)
207 {
208 CStdString strName = childNode->Value();
209
210 for (i = m_tagSet.begin(); i != m_tagSet.end(); i++)
211 {
2bf9126 fixed: rss feed could crash
bobbin007 authored
212 if (!childNode->NoChildren() && i->Equals(strName))
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
213 {
7c04d21 - 15-02-2006 fixed: Dialogs could vanish instead of changing the animat...
jmarshallnz authored
214 CStdString htmlText = childNode->FirstChild()->Value();
215
216 // This usually happens in right-to-left languages where they want to
217 // specify in the RSS body that the text should be RTL.
218 // <title>
025b9e5 fixed: Various compilation issues/warnings under win32
jmarshallnz authored
219 // <div dir="RTL">��� ����: ���� �� �����</div>
7c04d21 - 15-02-2006 fixed: Dialogs could vanish instead of changing the animat...
jmarshallnz authored
220 // </title>
221 if (htmlText.Equals("div") || htmlText.Equals("span"))
222 {
223 m_shouldFlip = true;
224 htmlText = childNode->FirstChild()->FirstChild()->Value();
225 }
226
227 CStdString text;
228 CStdStringW unicodeText;
229
230 html.ConvertHTMLToAnsi(htmlText, text);
231 fromRSSToUTF16(text, unicodeText);
232
233 mTagElements.insert(StrPair(*i, unicodeText));
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
234 }
235 }
236 childNode = childNode->NextSibling();
237 }
238
239 int rsscolour = RSS_COLOR_HEADLINE;
240 for (i = m_tagSet.begin();i != m_tagSet.end();i++)
241 {
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
242 map <CStdString, CStdStringW>::iterator j = mTagElements.find(*i);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
243
244 if (j == mTagElements.end())
245 continue;
7c04d21 - 15-02-2006 fixed: Dialogs could vanish instead of changing the animat...
jmarshallnz authored
246
247 CStdStringW& text = j->second;
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
248 AddString(text, rsscolour, iFeed);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
249 rsscolour = RSS_COLOR_BODY;
250 text = " - ";
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
251 AddString(text, rsscolour, iFeed);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
252 }
253 itemNode = itemNode->NextSiblingElement("item");
254 }
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
255 }
256
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
257 void CRssReader::fromRSSToUTF16(const CStdStringA& strSource, CStdStringW& strDest)
258 {
259 CStdString flippedStrSource;
260
261 if (m_shouldFlip)
262 {
22b20e4 Fix small bug with the text direction in bidi strings. This bug was caus...
yuvalt authored
263 g_charsetConverter.logicalToVisualBiDi(strSource, flippedStrSource, m_encoding, FRIBIDI_TYPE_RTL);
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
264 }
265 else
266 {
267 flippedStrSource = strSource;
268 }
269
270 if (m_iconv != (iconv_t) - 1)
271 {
272 const char* src = flippedStrSource.c_str();
273 size_t inBytes = flippedStrSource.length() + 1;
274
275 wchar_t outBuf[1024];
276 char* dst = (char*) &outBuf[0];
277 size_t outBytes=1024;
278 size_t originalOutBytes = outBytes;
279
280 iconv(m_iconv, NULL, &inBytes, NULL, &outBytes);
281
025b9e5 fixed: Various compilation issues/warnings under win32
jmarshallnz authored
282 #ifdef _LINUX
3074f40 Janitoring
yuvalt authored
283 if (iconv(m_iconv, (char**) &src, &inBytes, &dst, &outBytes) == (size_t) -1)
025b9e5 fixed: Various compilation issues/warnings under win32
jmarshallnz authored
284 #else
3074f40 Janitoring
yuvalt authored
285 if (iconv(m_iconv, &src, &inBytes, &dst, &outBytes) == (size_t) -1)
025b9e5 fixed: Various compilation issues/warnings under win32
jmarshallnz authored
286 #endif
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
287 {
288 // For some reason it failed (maybe wrong charset?). Nothing to do but
289 // return the original..
290 strDest = flippedStrSource;
291 return;
292 }
293
294 outBuf[(originalOutBytes - outBytes) / 2] = '\0';
295 strDest = outBuf;
296 }
297 else
298 {
299 strDest = flippedStrSource;
300 return;
301 }
302 }
303
304 bool CRssReader::Parse(LPSTR szBuffer, int iFeed)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
305 {
729886c added: sf.net patch [1209466] Multiple RSS feeds concatenated - thanks t...
spiff_ authored
306 m_xml.Clear();
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
307 m_xml.Parse((LPCSTR)szBuffer, 0, TIXML_ENCODING_LEGACY);
308
309 if (m_iconv != (iconv_t) -1)
310 {
311 iconv_close(m_iconv);
312 m_iconv = (iconv_t) -1;
313 m_shouldFlip = false;
314 }
315
316 m_encoding = "UTF-8";
317 if (m_xml.RootElement())
318 {
319 TiXmlDeclaration *tiXmlDeclaration = m_xml.RootElement()->Parent()->FirstChild()->ToDeclaration();
320 if (tiXmlDeclaration != NULL && strlen(tiXmlDeclaration->Encoding()) > 0)
321 {
322 m_encoding = tiXmlDeclaration->Encoding();
323 }
324 }
325
326 CLog::Log(LOGDEBUG, "RSS feed encoding: %s", m_encoding.c_str());
0cc90d3 Fix RSS loading under Linux
yuvalt authored
327 #ifndef _LINUX
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
328 m_iconv = iconv_open("UTF-16LE", m_encoding.c_str());
0cc90d3 Fix RSS loading under Linux
yuvalt authored
329 #else
330 m_iconv = iconv_open("WCHAR_T", m_encoding.c_str());
331 #endif
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
332
333 if (g_charsetConverter.isBidiCharset(m_encoding))
334 {
335 m_shouldFlip = true;
336 }
337
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
338 return Parse(iFeed);
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
339 }
340
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
341 bool CRssReader::Parse(int iFeed)
e688c17 runtime: Added a motherload of utils classes. All of these classes are ...
runtime authored
342 {
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
343 TiXmlElement* rootXmlNode = m_xml.RootElement();
344
345 if (!rootXmlNode)
346 return false;
347
348 TiXmlElement* rssXmlNode = NULL;
349
350 CStdString strValue = rootXmlNode->Value();
351 if (( strValue.Find("rss") >= 0 ) || ( strValue.Find("rdf") >= 0 ))
352 {
353 rssXmlNode = rootXmlNode;
354 }
355 else
356 {
357 // Unable to find root <rss> or <rdf> node
358 return false;
359 }
360
361 TiXmlElement* channelXmlNode = rssXmlNode->FirstChildElement("channel");
362 if (channelXmlNode)
363 {
364 TiXmlElement* titleNode = channelXmlNode->FirstChildElement("title");
2bf9126 fixed: rss feed could crash
bobbin007 authored
365 if (titleNode && !titleNode->NoChildren())
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
366 {
47e12be fixed: SF bug [ 1065692 ] RSS does not work for non-Latin character. You...
yuvalt authored
367 CStdString strChannel = titleNode->FirstChild()->Value();
368 CStdStringW strChannelUnicode;
369 fromRSSToUTF16(strChannel, strChannelUnicode);
370 AddString(strChannelUnicode, RSS_COLOR_CHANNEL, iFeed);
371
372 AddString(": ", RSS_COLOR_CHANNEL, iFeed);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
373 }
374
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
375 GetNewsItems(channelXmlNode,iFeed);
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
376 }
377
c7e2430 added: ability to select update interval for rss feeds.
spiff_ authored
378 GetNewsItems(rssXmlNode,iFeed);
7c04d21 - 15-02-2006 fixed: Dialogs could vanish instead of changing the animat...
jmarshallnz authored
379
380 // avoid trailing ' - '
381 if( m_strFeed[iFeed].size() > 3 && m_strFeed[iFeed].Mid(m_strFeed[iFeed].size()-3) == L" - ")
382 {
383 m_strFeed[iFeed].erase(m_strFeed[iFeed].length()-3);
384 m_strColors[iFeed].erase(m_strColors[iFeed].length()-3);
385 }
cf4743e Formatting for tabs -> 2 spaces
jmarshallnz authored
386 return true;
387 }
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
388
389 void CRssReader::SetObserver(IRssObserver *observer)
390 {
391 m_pObserver = observer;
392 }
393
394 void CRssReader::UpdateObserver()
395 {
396 if (!m_pObserver) return;
5e3f789 merge with trunk. revision 10882.
vulkanr authored
397 vector<DWORD> feed;
398 getFeed(feed);
399 if (feed.size() > 0)
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
400 {
5e3f789 merge with trunk. revision 10882.
vulkanr authored
401 m_pObserver->OnFeedUpdate(feed);
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
402 }
d604718 added cache system for CFile.
vulkanr authored
403 g_graphicsContext.Unlock();
404
4cbf417 - 26-07-2005 changed: Skin files are loaded on demand rather than on bo...
jmarshallnz authored
405 }
406
407 void CRssReader::CheckForUpdates()
408 {
409 SYSTEMTIME time;
410 GetLocalTime(&time);
411 for (unsigned int i = 0;i < m_vecUpdateTimes.size(); ++i )
412 {
413 if (((time.wDay * 24 * 60) + (time.wHour * 60) + time.wMinute) - ((m_vecTimeStamps[i]->wDay * 24 * 60) + (m_vecTimeStamps[i]->wHour * 60) + m_vecTimeStamps[i]->wMinute) > m_vecUpdateTimes[i] )
414 {
415 CLog::Log(LOGDEBUG, "Updating RSS");
416 GetLocalTime(m_vecTimeStamps[i]);
417 AddToQueue(i);
418 }
419 }
420 }
421
422 CRssManager g_rssManager;
423
424 CRssManager::CRssManager()
425 {
426 }
427
428 CRssManager::~CRssManager()
429 {
430 for (unsigned int i = 0; i < m_readers.size(); i++)
431 {
432 if (m_readers[i].reader)
433 {
434 m_readers[i].reader->StopThread();
435 delete m_readers[i].reader;
436 }
437 }
438 m_readers.clear();
439 }
440
441 // returns true if the reader doesn't need creating, false otherwise
442 bool CRssManager::GetReader(DWORD controlID, DWORD windowID, IRssObserver* observer, CRssReader *&reader)
443 {
444 // check to see if we've already created this reader
445 for (unsigned int i = 0; i < m_readers.size(); i++)
446 {
447 if (m_readers[i].controlID == controlID && m_readers[i].windowID == windowID)
448 {
449 reader = m_readers[i].reader;
450 reader->SetObserver(observer);
451 reader->UpdateObserver();
452 return true;
453 }
454 }
455 // need to create a new one
456 READERCONTROL readerControl;
457 readerControl.controlID = controlID;
458 readerControl.windowID = windowID;
459 reader = readerControl.reader = new CRssReader;
460 m_readers.push_back(readerControl);
461 return false;
462 }
Something went wrong with that request. Please try again.