1 /*
2  *  Copyright (C) 2005-2018 Team Kodi
3  *  This file is part of Kodi - https://kodi.tv
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSES/README.md for more information.
7  */
8 
9 #include "PVRRadioRDSInfoTag.h"
10 
11 #include "GUIUserMessages.h"
12 #include "ServiceBroker.h"
13 #include "guilib/GUIComponent.h"
14 #include "guilib/GUIMessage.h"
15 #include "guilib/GUIWindowManager.h"
16 #include "threads/SingleLock.h"
17 #include "utils/Archive.h"
18 #include "utils/CharsetConverter.h"
19 #include "utils/StringUtils.h"
20 #include "utils/Variant.h"
21 
22 #include <algorithm>
23 #include <string>
24 #include <utility>
25 
26 using namespace PVR;
27 
CPVRRadioRDSInfoTag()28 CPVRRadioRDSInfoTag::CPVRRadioRDSInfoTag()
29 {
30   Clear();
31 }
32 
Serialize(CVariant & value) const33 void CPVRRadioRDSInfoTag::Serialize(CVariant& value) const
34 {
35   CSingleLock lock(m_critSection);
36 
37   value["strLanguage"] = m_strLanguage;
38   value["strCountry"] = m_strCountry;
39   value["strTitle"] = m_strTitle;
40   value["strBand"] = m_strBand;
41   value["strArtist"] = m_strArtist;
42   value["strComposer"] = m_strComposer;
43   value["strConductor"] = m_strConductor;
44   value["strAlbum"] = m_strAlbum;
45   value["iAlbumTracknumber"] = m_iAlbumTracknumber;
46   value["strProgStation"] = m_strProgStation;
47   value["strProgStyle"] = m_strProgStyle;
48   value["strProgHost"] = m_strProgHost;
49   value["strProgWebsite"] = m_strProgWebsite;
50   value["strProgNow"] = m_strProgNow;
51   value["strProgNext"] = m_strProgNext;
52   value["strPhoneHotline"] = m_strPhoneHotline;
53   value["strEMailHotline"] = m_strEMailHotline;
54   value["strPhoneStudio"] = m_strPhoneStudio;
55   value["strEMailStudio"] = m_strEMailStudio;
56   value["strSMSStudio"] = m_strSMSStudio;
57   value["strRadioStyle"] = m_strRadioStyle;
58 }
59 
Archive(CArchive & ar)60 void CPVRRadioRDSInfoTag::Archive(CArchive& ar)
61 {
62   CSingleLock lock(m_critSection);
63 
64   if (ar.IsStoring())
65   {
66     ar << m_strLanguage;
67     ar << m_strCountry;
68     ar << m_strTitle;
69     ar << m_strBand;
70     ar << m_strArtist;
71     ar << m_strComposer;
72     ar << m_strConductor;
73     ar << m_strAlbum;
74     ar << m_iAlbumTracknumber;
75     ar << m_strProgStation;
76     ar << m_strProgStyle;
77     ar << m_strProgHost;
78     ar << m_strProgWebsite;
79     ar << m_strProgNow;
80     ar << m_strProgNext;
81     ar << m_strPhoneHotline;
82     ar << m_strEMailHotline;
83     ar << m_strPhoneStudio;
84     ar << m_strEMailStudio;
85     ar << m_strSMSStudio;
86     ar << m_strRadioStyle;
87   }
88   else
89   {
90     ar >> m_strLanguage;
91     ar >> m_strCountry;
92     ar >> m_strTitle;
93     ar >> m_strBand;
94     ar >> m_strArtist;
95     ar >> m_strComposer;
96     ar >> m_strConductor;
97     ar >> m_strAlbum;
98     ar >> m_iAlbumTracknumber;
99     ar >> m_strProgStation;
100     ar >> m_strProgStyle;
101     ar >> m_strProgHost;
102     ar >> m_strProgWebsite;
103     ar >> m_strProgNow;
104     ar >> m_strProgNext;
105     ar >> m_strPhoneHotline;
106     ar >> m_strEMailHotline;
107     ar >> m_strPhoneStudio;
108     ar >> m_strEMailStudio;
109     ar >> m_strSMSStudio;
110     ar >> m_strRadioStyle;
111   }
112 }
113 
operator ==(const CPVRRadioRDSInfoTag & right) const114 bool CPVRRadioRDSInfoTag::operator==(const CPVRRadioRDSInfoTag& right) const
115 {
116   if (this == &right)
117     return true;
118 
119   CSingleLock lock(m_critSection);
120   return (m_strLanguage == right.m_strLanguage &&
121           m_strCountry == right.m_strCountry &&
122           m_strTitle == right.m_strTitle &&
123           m_strBand == right.m_strBand &&
124           m_strArtist == right.m_strArtist &&
125           m_strComposer == right.m_strComposer &&
126           m_strConductor == right.m_strConductor &&
127           m_strAlbum == right.m_strAlbum &&
128           m_iAlbumTracknumber == right.m_iAlbumTracknumber &&
129           m_strInfoNews == right.m_strInfoNews &&
130           m_strInfoNewsLocal == right.m_strInfoNewsLocal &&
131           m_strInfoSport == right.m_strInfoSport &&
132           m_strInfoStock == right.m_strInfoStock &&
133           m_strInfoWeather == right.m_strInfoWeather &&
134           m_strInfoLottery == right.m_strInfoLottery &&
135           m_strInfoOther == right.m_strInfoOther &&
136           m_strProgStyle == right.m_strProgStyle &&
137           m_strProgHost == right.m_strProgHost &&
138           m_strProgStation == right.m_strProgStation &&
139           m_strProgWebsite == right.m_strProgWebsite &&
140           m_strProgNow == right.m_strProgNow &&
141           m_strProgNext == right.m_strProgNext &&
142           m_strPhoneHotline == right.m_strPhoneHotline &&
143           m_strEMailHotline == right.m_strEMailHotline &&
144           m_strPhoneStudio == right.m_strPhoneStudio &&
145           m_strEMailStudio == right.m_strEMailStudio &&
146           m_strSMSStudio == right.m_strSMSStudio &&
147           m_strRadioStyle == right.m_strRadioStyle &&
148           m_strInfoHoroscope == right.m_strInfoHoroscope &&
149           m_strInfoCinema == right.m_strInfoCinema &&
150           m_strComment == right.m_strComment &&
151           m_strEditorialStaff == right.m_strEditorialStaff &&
152           m_bHaveRadiotext == right.m_bHaveRadiotext &&
153           m_bHaveRadiotextPlus == right.m_bHaveRadiotextPlus);
154 }
155 
operator !=(const CPVRRadioRDSInfoTag & right) const156 bool CPVRRadioRDSInfoTag::operator !=(const CPVRRadioRDSInfoTag& right) const
157 {
158   if (this == &right)
159     return false;
160 
161   return !(*this == right);
162 }
163 
Clear()164 void CPVRRadioRDSInfoTag::Clear()
165 {
166   CSingleLock lock(m_critSection);
167 
168   m_RDS_SpeechActive = false;
169 
170   ResetSongInformation();
171 
172   m_strLanguage.erase();
173   m_strCountry.erase();
174   m_strComment.erase();
175   m_strInfoNews.Clear();
176   m_strInfoNewsLocal.Clear();
177   m_strInfoSport.Clear();
178   m_strInfoStock.Clear();
179   m_strInfoWeather.Clear();
180   m_strInfoLottery.Clear();
181   m_strInfoOther.Clear();
182   m_strInfoHoroscope.Clear();
183   m_strInfoCinema.Clear();
184   m_strProgStyle.erase();
185   m_strProgHost.erase();
186   m_strProgStation.erase();
187   m_strProgWebsite.erase();
188   m_strPhoneHotline.erase();
189   m_strEMailHotline.erase();
190   m_strPhoneStudio.erase();
191   m_strEMailStudio.erase();
192   m_strSMSStudio.erase();
193   m_strRadioStyle = "unknown";
194   m_strEditorialStaff.Clear();
195 
196   m_bHaveRadiotext = false;
197   m_bHaveRadiotextPlus = false;
198 }
199 
ResetSongInformation()200 void CPVRRadioRDSInfoTag::ResetSongInformation()
201 {
202   CSingleLock lock(m_critSection);
203 
204   m_strTitle.erase();
205   m_strBand.erase();
206   m_strArtist.erase();
207   m_strComposer.erase();
208   m_strConductor.erase();
209   m_strAlbum.erase();
210   m_iAlbumTracknumber = 0;
211 }
212 
SetSpeechActive(bool active)213 void CPVRRadioRDSInfoTag::SetSpeechActive(bool active)
214 {
215   CSingleLock lock(m_critSection);
216   m_RDS_SpeechActive = active;
217 }
218 
SetLanguage(const std::string & strLanguage)219 void CPVRRadioRDSInfoTag::SetLanguage(const std::string& strLanguage)
220 {
221   CSingleLock lock(m_critSection);
222   m_strLanguage = Trim(strLanguage);
223 }
224 
GetLanguage() const225 const std::string& CPVRRadioRDSInfoTag::GetLanguage() const
226 {
227   CSingleLock lock(m_critSection);
228   return m_strLanguage;
229 }
230 
SetCountry(const std::string & strCountry)231 void CPVRRadioRDSInfoTag::SetCountry(const std::string& strCountry)
232 {
233   CSingleLock lock(m_critSection);
234   m_strCountry = Trim(strCountry);
235 }
236 
GetCountry() const237 const std::string& CPVRRadioRDSInfoTag::GetCountry() const
238 {
239   CSingleLock lock(m_critSection);
240   return m_strCountry;
241 }
242 
SetTitle(const std::string & strTitle)243 void CPVRRadioRDSInfoTag::SetTitle(const std::string& strTitle)
244 {
245   CSingleLock lock(m_critSection);
246   m_strTitle = Trim(strTitle);
247 }
248 
SetArtist(const std::string & strArtist)249 void CPVRRadioRDSInfoTag::SetArtist(const std::string& strArtist)
250 {
251   CSingleLock lock(m_critSection);
252   m_strArtist = Trim(strArtist);
253 }
254 
SetBand(const std::string & strBand)255 void CPVRRadioRDSInfoTag::SetBand(const std::string& strBand)
256 {
257   CSingleLock lock(m_critSection);
258   m_strBand = Trim(strBand);
259   g_charsetConverter.unknownToUTF8(m_strBand);
260 }
261 
SetComposer(const std::string & strComposer)262 void CPVRRadioRDSInfoTag::SetComposer(const std::string& strComposer)
263 {
264   CSingleLock lock(m_critSection);
265   m_strComposer = Trim(strComposer);
266   g_charsetConverter.unknownToUTF8(m_strComposer);
267 }
268 
SetConductor(const std::string & strConductor)269 void CPVRRadioRDSInfoTag::SetConductor(const std::string& strConductor)
270 {
271   CSingleLock lock(m_critSection);
272   m_strConductor = Trim(strConductor);
273   g_charsetConverter.unknownToUTF8(m_strConductor);
274 }
275 
SetAlbum(const std::string & strAlbum)276 void CPVRRadioRDSInfoTag::SetAlbum(const std::string& strAlbum)
277 {
278   CSingleLock lock(m_critSection);
279   m_strAlbum = Trim(strAlbum);
280   g_charsetConverter.unknownToUTF8(m_strAlbum);
281 }
282 
SetAlbumTrackNumber(int track)283 void CPVRRadioRDSInfoTag::SetAlbumTrackNumber(int track)
284 {
285   CSingleLock lock(m_critSection);
286   m_iAlbumTracknumber = track;
287 }
288 
SetComment(const std::string & strComment)289 void CPVRRadioRDSInfoTag::SetComment(const std::string& strComment)
290 {
291   CSingleLock lock(m_critSection);
292   m_strComment = Trim(strComment);
293   g_charsetConverter.unknownToUTF8(m_strComment);
294 }
295 
GetTitle() const296 const std::string& CPVRRadioRDSInfoTag::GetTitle() const
297 {
298   CSingleLock lock(m_critSection);
299   return m_strTitle;
300 }
301 
GetArtist() const302 const std::string& CPVRRadioRDSInfoTag::GetArtist() const
303 {
304   CSingleLock lock(m_critSection);
305   return m_strArtist;
306 }
307 
GetBand() const308 const std::string& CPVRRadioRDSInfoTag::GetBand() const
309 {
310   CSingleLock lock(m_critSection);
311   return m_strBand;
312 }
313 
GetComposer() const314 const std::string& CPVRRadioRDSInfoTag::GetComposer() const
315 {
316   CSingleLock lock(m_critSection);
317   return m_strComposer;
318 }
319 
GetConductor() const320 const std::string& CPVRRadioRDSInfoTag::GetConductor() const
321 {
322   CSingleLock lock(m_critSection);
323   return m_strConductor;
324 }
325 
GetAlbum() const326 const std::string& CPVRRadioRDSInfoTag::GetAlbum() const
327 {
328   CSingleLock lock(m_critSection);
329   return m_strAlbum;
330 }
331 
GetAlbumTrackNumber() const332 int CPVRRadioRDSInfoTag::GetAlbumTrackNumber() const
333 {
334   CSingleLock lock(m_critSection);
335   return m_iAlbumTracknumber;
336 }
337 
GetComment() const338 const std::string& CPVRRadioRDSInfoTag::GetComment() const
339 {
340   CSingleLock lock(m_critSection);
341   return m_strComment;
342 }
343 
SetInfoNews(const std::string & strNews)344 void CPVRRadioRDSInfoTag::SetInfoNews(const std::string& strNews)
345 {
346   CSingleLock lock(m_critSection);
347   m_strInfoNews.Add(strNews);
348 }
349 
GetInfoNews() const350 const std::string CPVRRadioRDSInfoTag::GetInfoNews() const
351 {
352   CSingleLock lock(m_critSection);
353   return m_strInfoNews.GetText();
354 }
355 
SetInfoNewsLocal(const std::string & strNews)356 void CPVRRadioRDSInfoTag::SetInfoNewsLocal(const std::string& strNews)
357 {
358   CSingleLock lock(m_critSection);
359   m_strInfoNewsLocal.Add(strNews);
360 }
361 
GetInfoNewsLocal() const362 const std::string CPVRRadioRDSInfoTag::GetInfoNewsLocal() const
363 {
364   CSingleLock lock(m_critSection);
365   return m_strInfoNewsLocal.GetText();
366 }
367 
SetInfoSport(const std::string & strSport)368 void CPVRRadioRDSInfoTag::SetInfoSport(const std::string& strSport)
369 {
370   CSingleLock lock(m_critSection);
371   m_strInfoSport.Add(strSport);
372 }
373 
GetInfoSport() const374 const std::string CPVRRadioRDSInfoTag::GetInfoSport() const
375 {
376   CSingleLock lock(m_critSection);
377   return m_strInfoSport.GetText();
378 }
379 
SetInfoStock(const std::string & strStock)380 void CPVRRadioRDSInfoTag::SetInfoStock(const std::string& strStock)
381 {
382   CSingleLock lock(m_critSection);
383   m_strInfoStock.Add(strStock);
384 }
385 
GetInfoStock() const386 const std::string CPVRRadioRDSInfoTag::GetInfoStock() const
387 {
388   CSingleLock lock(m_critSection);
389   return m_strInfoStock.GetText();
390 }
391 
SetInfoWeather(const std::string & strWeather)392 void CPVRRadioRDSInfoTag::SetInfoWeather(const std::string& strWeather)
393 {
394   CSingleLock lock(m_critSection);
395   m_strInfoWeather.Add(strWeather);
396 }
397 
GetInfoWeather() const398 const std::string CPVRRadioRDSInfoTag::GetInfoWeather() const
399 {
400   CSingleLock lock(m_critSection);
401   return m_strInfoWeather.GetText();
402 }
403 
SetInfoLottery(const std::string & strLottery)404 void CPVRRadioRDSInfoTag::SetInfoLottery(const std::string& strLottery)
405 {
406   CSingleLock lock(m_critSection);
407   m_strInfoLottery.Add(strLottery);
408 }
409 
GetInfoLottery() const410 const std::string CPVRRadioRDSInfoTag::GetInfoLottery() const
411 {
412   CSingleLock lock(m_critSection);
413   return m_strInfoLottery.GetText();
414 }
415 
SetEditorialStaff(const std::string & strEditorialStaff)416 void CPVRRadioRDSInfoTag::SetEditorialStaff(const std::string& strEditorialStaff)
417 {
418   CSingleLock lock(m_critSection);
419   m_strEditorialStaff.Add(strEditorialStaff);
420 }
421 
GetEditorialStaff() const422 const std::string CPVRRadioRDSInfoTag::GetEditorialStaff() const
423 {
424   CSingleLock lock(m_critSection);
425   return m_strEditorialStaff.GetText();
426 }
427 
SetInfoHoroscope(const std::string & strHoroscope)428 void CPVRRadioRDSInfoTag::SetInfoHoroscope(const std::string& strHoroscope)
429 {
430   CSingleLock lock(m_critSection);
431   m_strInfoHoroscope.Add(strHoroscope);
432 }
433 
GetInfoHoroscope() const434 const std::string CPVRRadioRDSInfoTag::GetInfoHoroscope() const
435 {
436   CSingleLock lock(m_critSection);
437   return m_strInfoHoroscope.GetText();
438 }
439 
SetInfoCinema(const std::string & strCinema)440 void CPVRRadioRDSInfoTag::SetInfoCinema(const std::string& strCinema)
441 {
442   CSingleLock lock(m_critSection);
443   m_strInfoCinema.Add(strCinema);
444 }
445 
GetInfoCinema() const446 const std::string CPVRRadioRDSInfoTag::GetInfoCinema() const
447 {
448   CSingleLock lock(m_critSection);
449   return m_strInfoCinema.GetText();
450 }
451 
SetInfoOther(const std::string & strOther)452 void CPVRRadioRDSInfoTag::SetInfoOther(const std::string& strOther)
453 {
454   CSingleLock lock(m_critSection);
455   m_strInfoOther.Add(strOther);
456 }
457 
GetInfoOther() const458 const std::string CPVRRadioRDSInfoTag::GetInfoOther() const
459 {
460   CSingleLock lock(m_critSection);
461   return m_strInfoOther.GetText();
462 }
463 
SetProgStation(const std::string & strProgStation)464 void CPVRRadioRDSInfoTag::SetProgStation(const std::string& strProgStation)
465 {
466   CSingleLock lock(m_critSection);
467   m_strProgStation = Trim(strProgStation);
468   g_charsetConverter.unknownToUTF8(m_strProgStation);
469 }
470 
SetProgHost(const std::string & strProgHost)471 void CPVRRadioRDSInfoTag::SetProgHost(const std::string& strProgHost)
472 {
473   CSingleLock lock(m_critSection);
474   m_strProgHost = Trim(strProgHost);
475   g_charsetConverter.unknownToUTF8(m_strProgHost);
476 }
477 
SetProgStyle(const std::string & strProgStyle)478 void CPVRRadioRDSInfoTag::SetProgStyle(const std::string& strProgStyle)
479 {
480   CSingleLock lock(m_critSection);
481   m_strProgStyle = Trim(strProgStyle);
482   g_charsetConverter.unknownToUTF8(m_strProgStyle);
483 }
484 
SetProgWebsite(const std::string & strWebsite)485 void CPVRRadioRDSInfoTag::SetProgWebsite(const std::string& strWebsite)
486 {
487   CSingleLock lock(m_critSection);
488   m_strProgWebsite = Trim(strWebsite);
489   g_charsetConverter.unknownToUTF8(m_strProgWebsite);
490 }
491 
SetProgNow(const std::string & strNow)492 void CPVRRadioRDSInfoTag::SetProgNow(const std::string& strNow)
493 {
494   CSingleLock lock(m_critSection);
495   m_strProgNow = Trim(strNow);
496   g_charsetConverter.unknownToUTF8(m_strProgNow);
497 }
498 
SetProgNext(const std::string & strNext)499 void CPVRRadioRDSInfoTag::SetProgNext(const std::string& strNext)
500 {
501   CSingleLock lock(m_critSection);
502   m_strProgNext = Trim(strNext);
503   g_charsetConverter.unknownToUTF8(m_strProgNext);
504 }
505 
SetPhoneHotline(const std::string & strHotline)506 void CPVRRadioRDSInfoTag::SetPhoneHotline(const std::string& strHotline)
507 {
508   CSingleLock lock(m_critSection);
509   m_strPhoneHotline = Trim(strHotline);
510   g_charsetConverter.unknownToUTF8(m_strPhoneHotline);
511 }
512 
SetEMailHotline(const std::string & strHotline)513 void CPVRRadioRDSInfoTag::SetEMailHotline(const std::string& strHotline)
514 {
515   CSingleLock lock(m_critSection);
516   m_strEMailHotline = Trim(strHotline);
517   g_charsetConverter.unknownToUTF8(m_strEMailHotline);
518 }
519 
SetPhoneStudio(const std::string & strPhone)520 void CPVRRadioRDSInfoTag::SetPhoneStudio(const std::string& strPhone)
521 {
522   CSingleLock lock(m_critSection);
523   m_strPhoneStudio = Trim(strPhone);
524   g_charsetConverter.unknownToUTF8(m_strPhoneStudio);
525 }
526 
SetEMailStudio(const std::string & strEMail)527 void CPVRRadioRDSInfoTag::SetEMailStudio(const std::string& strEMail)
528 {
529   CSingleLock lock(m_critSection);
530   m_strEMailStudio = Trim(strEMail);
531   g_charsetConverter.unknownToUTF8(m_strEMailStudio);
532 }
533 
SetSMSStudio(const std::string & strSMS)534 void CPVRRadioRDSInfoTag::SetSMSStudio(const std::string& strSMS)
535 {
536   CSingleLock lock(m_critSection);
537   m_strSMSStudio = Trim(strSMS);
538   g_charsetConverter.unknownToUTF8(m_strSMSStudio);
539 }
540 
GetProgStyle() const541 const std::string& CPVRRadioRDSInfoTag::GetProgStyle() const
542 {
543   CSingleLock lock(m_critSection);
544   return m_strProgStyle;
545 }
546 
GetProgHost() const547 const std::string& CPVRRadioRDSInfoTag::GetProgHost() const
548 {
549   CSingleLock lock(m_critSection);
550   return m_strProgHost;
551 }
552 
GetProgStation() const553 const std::string& CPVRRadioRDSInfoTag::GetProgStation() const
554 {
555   CSingleLock lock(m_critSection);
556   return m_strProgStation;
557 }
558 
GetProgWebsite() const559 const std::string& CPVRRadioRDSInfoTag::GetProgWebsite() const
560 {
561   CSingleLock lock(m_critSection);
562   return m_strProgWebsite;
563 }
564 
GetProgNow() const565 const std::string& CPVRRadioRDSInfoTag::GetProgNow() const
566 {
567   CSingleLock lock(m_critSection);
568   return m_strProgNow;
569 }
570 
GetProgNext() const571 const std::string& CPVRRadioRDSInfoTag::GetProgNext() const
572 {
573   CSingleLock lock(m_critSection);
574   return m_strProgNext;
575 }
576 
GetPhoneHotline() const577 const std::string& CPVRRadioRDSInfoTag::GetPhoneHotline() const
578 {
579   CSingleLock lock(m_critSection);
580   return m_strPhoneHotline;
581 }
582 
GetEMailHotline() const583 const std::string& CPVRRadioRDSInfoTag::GetEMailHotline() const
584 {
585   CSingleLock lock(m_critSection);
586   return m_strEMailHotline;
587 }
588 
GetPhoneStudio() const589 const std::string& CPVRRadioRDSInfoTag::GetPhoneStudio() const
590 {
591   CSingleLock lock(m_critSection);
592   return m_strPhoneStudio;
593 }
594 
GetEMailStudio() const595 const std::string& CPVRRadioRDSInfoTag::GetEMailStudio() const
596 {
597   CSingleLock lock(m_critSection);
598   return m_strEMailStudio;
599 }
600 
GetSMSStudio() const601 const std::string& CPVRRadioRDSInfoTag::GetSMSStudio() const
602 {
603   CSingleLock lock(m_critSection);
604   return m_strSMSStudio;
605 }
606 
SetRadioStyle(const std::string & style)607 void CPVRRadioRDSInfoTag::SetRadioStyle(const std::string& style)
608 {
609   CSingleLock lock(m_critSection);
610   m_strRadioStyle = style;
611 }
612 
GetRadioStyle() const613 const std::string CPVRRadioRDSInfoTag::GetRadioStyle() const
614 {
615   CSingleLock lock(m_critSection);
616   return m_strRadioStyle;
617 }
618 
SetPlayingRadiotext(bool yesNo)619 void CPVRRadioRDSInfoTag::SetPlayingRadiotext(bool yesNo)
620 {
621   CSingleLock lock(m_critSection);
622   m_bHaveRadiotext = yesNo;
623 }
624 
IsPlayingRadiotext() const625 bool CPVRRadioRDSInfoTag::IsPlayingRadiotext() const
626 {
627   CSingleLock lock(m_critSection);
628   return m_bHaveRadiotext;
629 }
630 
SetPlayingRadiotextPlus(bool yesNo)631 void CPVRRadioRDSInfoTag::SetPlayingRadiotextPlus(bool yesNo)
632 {
633   CSingleLock lock(m_critSection);
634   m_bHaveRadiotextPlus = yesNo;
635 }
636 
IsPlayingRadiotextPlus() const637 bool CPVRRadioRDSInfoTag::IsPlayingRadiotextPlus() const
638 {
639   CSingleLock lock(m_critSection);
640   return m_bHaveRadiotextPlus;
641 }
642 
Trim(const std::string & value)643 std::string CPVRRadioRDSInfoTag::Trim(const std::string& value)
644 {
645   std::string trimmedValue(value);
646   StringUtils::TrimLeft(trimmedValue);
647   StringUtils::TrimRight(trimmedValue, " \n\r");
648   return trimmedValue;
649 }
650 
operator ==(const CPVRRadioRDSInfoTag::Info & right) const651 bool CPVRRadioRDSInfoTag::Info::operator==(const CPVRRadioRDSInfoTag::Info& right) const
652 {
653   if (this == &right)
654     return true;
655 
656   return (m_infoText == right.m_infoText &&
657           m_data == right.m_data);
658 }
659 
Clear()660 void CPVRRadioRDSInfoTag::Info::Clear()
661 {
662   m_data.clear();
663   m_infoText.clear();
664 }
665 
Add(const std::string & text)666 void CPVRRadioRDSInfoTag::Info::Add(const std::string& text)
667 {
668   std::string tmp = Trim(text);
669   g_charsetConverter.unknownToUTF8(tmp);
670 
671   if (std::find(m_data.begin(), m_data.end(), tmp) != m_data.end())
672     return;
673 
674   if (m_data.size() >= 10)
675     m_data.pop_front();
676 
677   m_data.emplace_back(std::move(tmp));
678 
679   m_infoText.clear();
680   for (const std::string& data : m_data)
681   {
682     m_infoText += data;
683     m_infoText += '\n';
684   }
685 
686   // send a message to all windows to tell them to update the radiotext
687   CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_RADIOTEXT);
688   CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg);
689 }
690