Debian Codegraph @

xbmc/pvr/channels/PVRRadioRDSInfoTag.cpp

raw
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 "utils/Archive.h"
17 #include "utils/CharsetConverter.h"
18 #include "utils/StringUtils.h"
19 #include "utils/Variant.h"
20
21 #include <algorithm>
22 #include <mutex>
23 #include <string>
24 #include <utility>
25
26 using namespace PVR;
27
28 CPVRRadioRDSInfoTag::CPVRRadioRDSInfoTag()
29 {
30 Clear();
31 }
32
33 void CPVRRadioRDSInfoTag::Serialize(CVariant& value) const
34 {
35 std::unique_lock<CCriticalSection> 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
60 void CPVRRadioRDSInfoTag::Archive(CArchive& ar)
61 {
62 std::unique_lock<CCriticalSection> 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
114 bool CPVRRadioRDSInfoTag::operator==(const CPVRRadioRDSInfoTag& right) const
115 {
116 if (this == &right)
117 return true;
118
119 std::unique_lock<CCriticalSection> lock(m_critSection);
120 return (
121 m_strLanguage == right.m_strLanguage && m_strCountry == right.m_strCountry &&
122 m_strTitle == right.m_strTitle && m_strBand == right.m_strBand &&
123 m_strArtist == right.m_strArtist && m_strComposer == right.m_strComposer &&
124 m_strConductor == right.m_strConductor && m_strAlbum == right.m_strAlbum &&
125 m_iAlbumTracknumber == right.m_iAlbumTracknumber && m_strInfoNews == right.m_strInfoNews &&
126 m_strInfoNewsLocal == right.m_strInfoNewsLocal && m_strInfoSport == right.m_strInfoSport &&
127 m_strInfoStock == right.m_strInfoStock && m_strInfoWeather == right.m_strInfoWeather &&
128 m_strInfoLottery == right.m_strInfoLottery && m_strInfoOther == right.m_strInfoOther &&
129 m_strProgStyle == right.m_strProgStyle && m_strProgHost == right.m_strProgHost &&
130 m_strProgStation == right.m_strProgStation && m_strProgWebsite == right.m_strProgWebsite &&
131 m_strProgNow == right.m_strProgNow && m_strProgNext == right.m_strProgNext &&
132 m_strPhoneHotline == right.m_strPhoneHotline &&
133 m_strEMailHotline == right.m_strEMailHotline && m_strPhoneStudio == right.m_strPhoneStudio &&
134 m_strEMailStudio == right.m_strEMailStudio && m_strSMSStudio == right.m_strSMSStudio &&
135 m_strRadioStyle == right.m_strRadioStyle && m_strInfoHoroscope == right.m_strInfoHoroscope &&
136 m_strInfoCinema == right.m_strInfoCinema && m_strComment == right.m_strComment &&
137 m_strEditorialStaff == right.m_strEditorialStaff && m_strRadioText == right.m_strRadioText &&
138 m_strProgramServiceText == right.m_strProgramServiceText &&
139 m_strProgramServiceLine0 == right.m_strProgramServiceLine0 &&
140 m_strProgramServiceLine1 == right.m_strProgramServiceLine1 &&
141 m_bHaveRadioText == right.m_bHaveRadioText &&
142 m_bHaveRadioTextPlus == right.m_bHaveRadioTextPlus);
143 }
144
145 bool CPVRRadioRDSInfoTag::operator !=(const CPVRRadioRDSInfoTag& right) const
146 {
147 if (this == &right)
148 return false;
149
150 return !(*this == right);
151 }
152
153 void CPVRRadioRDSInfoTag::Clear()
154 {
155 std::unique_lock<CCriticalSection> lock(m_critSection);
156
157 m_RDS_SpeechActive = false;
158
159 ResetSongInformation();
160
161 m_strLanguage.erase();
162 m_strCountry.erase();
163 m_strComment.erase();
164 m_strInfoNews.Clear();
165 m_strInfoNewsLocal.Clear();
166 m_strInfoSport.Clear();
167 m_strInfoStock.Clear();
168 m_strInfoWeather.Clear();
169 m_strInfoLottery.Clear();
170 m_strInfoOther.Clear();
171 m_strInfoHoroscope.Clear();
172 m_strInfoCinema.Clear();
173 m_strProgStyle.erase();
174 m_strProgHost.erase();
175 m_strProgStation.erase();
176 m_strProgWebsite.erase();
177 m_strPhoneHotline.erase();
178 m_strEMailHotline.erase();
179 m_strPhoneStudio.erase();
180 m_strEMailStudio.erase();
181 m_strSMSStudio.erase();
182 m_strRadioStyle = "unknown";
183 m_strEditorialStaff.Clear();
184 m_strRadioText.Clear();
185 m_strProgramServiceText.Clear();
186 m_strProgramServiceLine0.erase();
187 m_strProgramServiceLine1.erase();
188
189 m_bHaveRadioText = false;
190 m_bHaveRadioTextPlus = false;
191 }
192
193 void CPVRRadioRDSInfoTag::ResetSongInformation()
194 {
195 std::unique_lock<CCriticalSection> lock(m_critSection);
196
197 m_strTitle.erase();
198 m_strBand.erase();
199 m_strArtist.erase();
200 m_strComposer.erase();
201 m_strConductor.erase();
202 m_strAlbum.erase();
203 m_iAlbumTracknumber = 0;
204 }
205
206 void CPVRRadioRDSInfoTag::SetSpeechActive(bool active)
207 {
208 std::unique_lock<CCriticalSection> lock(m_critSection);
209 m_RDS_SpeechActive = active;
210 }
211
212 void CPVRRadioRDSInfoTag::SetLanguage(const std::string& strLanguage)
213 {
214 std::unique_lock<CCriticalSection> lock(m_critSection);
215 m_strLanguage = Trim(strLanguage);
216 }
217
218 const std::string& CPVRRadioRDSInfoTag::GetLanguage() const
219 {
220 std::unique_lock<CCriticalSection> lock(m_critSection);
221 return m_strLanguage;
222 }
223
224 void CPVRRadioRDSInfoTag::SetCountry(const std::string& strCountry)
225 {
226 std::unique_lock<CCriticalSection> lock(m_critSection);
227 m_strCountry = Trim(strCountry);
228 }
229
230 const std::string& CPVRRadioRDSInfoTag::GetCountry() const
231 {
232 std::unique_lock<CCriticalSection> lock(m_critSection);
233 return m_strCountry;
234 }
235
236 void CPVRRadioRDSInfoTag::SetTitle(const std::string& strTitle)
237 {
238 std::unique_lock<CCriticalSection> lock(m_critSection);
239 m_strTitle = Trim(strTitle);
240 }
241
242 void CPVRRadioRDSInfoTag::SetArtist(const std::string& strArtist)
243 {
244 std::unique_lock<CCriticalSection> lock(m_critSection);
245 m_strArtist = Trim(strArtist);
246 }
247
248 void CPVRRadioRDSInfoTag::SetBand(const std::string& strBand)
249 {
250 std::unique_lock<CCriticalSection> lock(m_critSection);
251 m_strBand = Trim(strBand);
252 g_charsetConverter.unknownToUTF8(m_strBand);
253 }
254
255 void CPVRRadioRDSInfoTag::SetComposer(const std::string& strComposer)
256 {
257 std::unique_lock<CCriticalSection> lock(m_critSection);
258 m_strComposer = Trim(strComposer);
259 g_charsetConverter.unknownToUTF8(m_strComposer);
260 }
261
262 void CPVRRadioRDSInfoTag::SetConductor(const std::string& strConductor)
263 {
264 std::unique_lock<CCriticalSection> lock(m_critSection);
265 m_strConductor = Trim(strConductor);
266 g_charsetConverter.unknownToUTF8(m_strConductor);
267 }
268
269 void CPVRRadioRDSInfoTag::SetAlbum(const std::string& strAlbum)
270 {
271 std::unique_lock<CCriticalSection> lock(m_critSection);
272 m_strAlbum = Trim(strAlbum);
273 g_charsetConverter.unknownToUTF8(m_strAlbum);
274 }
275
276 void CPVRRadioRDSInfoTag::SetAlbumTrackNumber(int track)
277 {
278 std::unique_lock<CCriticalSection> lock(m_critSection);
279 m_iAlbumTracknumber = track;
280 }
281
282 void CPVRRadioRDSInfoTag::SetComment(const std::string& strComment)
283 {
284 std::unique_lock<CCriticalSection> lock(m_critSection);
285 m_strComment = Trim(strComment);
286 g_charsetConverter.unknownToUTF8(m_strComment);
287 }
288
289 const std::string& CPVRRadioRDSInfoTag::GetTitle() const
290 {
291 std::unique_lock<CCriticalSection> lock(m_critSection);
292 return m_strTitle;
293 }
294
295 const std::string& CPVRRadioRDSInfoTag::GetArtist() const
296 {
297 std::unique_lock<CCriticalSection> lock(m_critSection);
298 return m_strArtist;
299 }
300
301 const std::string& CPVRRadioRDSInfoTag::GetBand() const
302 {
303 std::unique_lock<CCriticalSection> lock(m_critSection);
304 return m_strBand;
305 }
306
307 const std::string& CPVRRadioRDSInfoTag::GetComposer() const
308 {
309 std::unique_lock<CCriticalSection> lock(m_critSection);
310 return m_strComposer;
311 }
312
313 const std::string& CPVRRadioRDSInfoTag::GetConductor() const
314 {
315 std::unique_lock<CCriticalSection> lock(m_critSection);
316 return m_strConductor;
317 }
318
319 const std::string& CPVRRadioRDSInfoTag::GetAlbum() const
320 {
321 std::unique_lock<CCriticalSection> lock(m_critSection);
322 return m_strAlbum;
323 }
324
325 int CPVRRadioRDSInfoTag::GetAlbumTrackNumber() const
326 {
327 std::unique_lock<CCriticalSection> lock(m_critSection);
328 return m_iAlbumTracknumber;
329 }
330
331 const std::string& CPVRRadioRDSInfoTag::GetComment() const
332 {
333 std::unique_lock<CCriticalSection> lock(m_critSection);
334 return m_strComment;
335 }
336
337 void CPVRRadioRDSInfoTag::SetInfoNews(const std::string& strNews)
338 {
339 std::unique_lock<CCriticalSection> lock(m_critSection);
340 m_strInfoNews.Add(strNews);
341 }
342
343 const std::string CPVRRadioRDSInfoTag::GetInfoNews() const
344 {
345 std::unique_lock<CCriticalSection> lock(m_critSection);
346 return m_strInfoNews.GetText();
347 }
348
349 void CPVRRadioRDSInfoTag::SetInfoNewsLocal(const std::string& strNews)
350 {
351 std::unique_lock<CCriticalSection> lock(m_critSection);
352 m_strInfoNewsLocal.Add(strNews);
353 }
354
355 const std::string CPVRRadioRDSInfoTag::GetInfoNewsLocal() const
356 {
357 std::unique_lock<CCriticalSection> lock(m_critSection);
358 return m_strInfoNewsLocal.GetText();
359 }
360
361 void CPVRRadioRDSInfoTag::SetInfoSport(const std::string& strSport)
362 {
363 std::unique_lock<CCriticalSection> lock(m_critSection);
364 m_strInfoSport.Add(strSport);
365 }
366
367 const std::string CPVRRadioRDSInfoTag::GetInfoSport() const
368 {
369 std::unique_lock<CCriticalSection> lock(m_critSection);
370 return m_strInfoSport.GetText();
371 }
372
373 void CPVRRadioRDSInfoTag::SetInfoStock(const std::string& strStock)
374 {
375 std::unique_lock<CCriticalSection> lock(m_critSection);
376 m_strInfoStock.Add(strStock);
377 }
378
379 const std::string CPVRRadioRDSInfoTag::GetInfoStock() const
380 {
381 std::unique_lock<CCriticalSection> lock(m_critSection);
382 return m_strInfoStock.GetText();
383 }
384
385 void CPVRRadioRDSInfoTag::SetInfoWeather(const std::string& strWeather)
386 {
387 std::unique_lock<CCriticalSection> lock(m_critSection);
388 m_strInfoWeather.Add(strWeather);
389 }
390
391 const std::string CPVRRadioRDSInfoTag::GetInfoWeather() const
392 {
393 std::unique_lock<CCriticalSection> lock(m_critSection);
394 return m_strInfoWeather.GetText();
395 }
396
397 void CPVRRadioRDSInfoTag::SetInfoLottery(const std::string& strLottery)
398 {
399 std::unique_lock<CCriticalSection> lock(m_critSection);
400 m_strInfoLottery.Add(strLottery);
401 }
402
403 const std::string CPVRRadioRDSInfoTag::GetInfoLottery() const
404 {
405 std::unique_lock<CCriticalSection> lock(m_critSection);
406 return m_strInfoLottery.GetText();
407 }
408
409 void CPVRRadioRDSInfoTag::SetEditorialStaff(const std::string& strEditorialStaff)
410 {
411 std::unique_lock<CCriticalSection> lock(m_critSection);
412 m_strEditorialStaff.Add(strEditorialStaff);
413 }
414
415 const std::string CPVRRadioRDSInfoTag::GetEditorialStaff() const
416 {
417 std::unique_lock<CCriticalSection> lock(m_critSection);
418 return m_strEditorialStaff.GetText();
419 }
420
421 void CPVRRadioRDSInfoTag::SetInfoHoroscope(const std::string& strHoroscope)
422 {
423 std::unique_lock<CCriticalSection> lock(m_critSection);
424 m_strInfoHoroscope.Add(strHoroscope);
425 }
426
427 const std::string CPVRRadioRDSInfoTag::GetInfoHoroscope() const
428 {
429 std::unique_lock<CCriticalSection> lock(m_critSection);
430 return m_strInfoHoroscope.GetText();
431 }
432
433 void CPVRRadioRDSInfoTag::SetInfoCinema(const std::string& strCinema)
434 {
435 std::unique_lock<CCriticalSection> lock(m_critSection);
436 m_strInfoCinema.Add(strCinema);
437 }
438
439 const std::string CPVRRadioRDSInfoTag::GetInfoCinema() const
440 {
441 std::unique_lock<CCriticalSection> lock(m_critSection);
442 return m_strInfoCinema.GetText();
443 }
444
445 void CPVRRadioRDSInfoTag::SetInfoOther(const std::string& strOther)
446 {
447 std::unique_lock<CCriticalSection> lock(m_critSection);
448 m_strInfoOther.Add(strOther);
449 }
450
451 const std::string CPVRRadioRDSInfoTag::GetInfoOther() const
452 {
453 std::unique_lock<CCriticalSection> lock(m_critSection);
454 return m_strInfoOther.GetText();
455 }
456
457 void CPVRRadioRDSInfoTag::SetProgStation(const std::string& strProgStation)
458 {
459 std::unique_lock<CCriticalSection> lock(m_critSection);
460 m_strProgStation = Trim(strProgStation);
461 g_charsetConverter.unknownToUTF8(m_strProgStation);
462 }
463
464 void CPVRRadioRDSInfoTag::SetProgHost(const std::string& strProgHost)
465 {
466 std::unique_lock<CCriticalSection> lock(m_critSection);
467 m_strProgHost = Trim(strProgHost);
468 g_charsetConverter.unknownToUTF8(m_strProgHost);
469 }
470
471 void CPVRRadioRDSInfoTag::SetProgStyle(const std::string& strProgStyle)
472 {
473 std::unique_lock<CCriticalSection> lock(m_critSection);
474 m_strProgStyle = Trim(strProgStyle);
475 g_charsetConverter.unknownToUTF8(m_strProgStyle);
476 }
477
478 void CPVRRadioRDSInfoTag::SetProgWebsite(const std::string& strWebsite)
479 {
480 std::unique_lock<CCriticalSection> lock(m_critSection);
481 m_strProgWebsite = Trim(strWebsite);
482 g_charsetConverter.unknownToUTF8(m_strProgWebsite);
483 }
484
485 void CPVRRadioRDSInfoTag::SetProgNow(const std::string& strNow)
486 {
487 std::unique_lock<CCriticalSection> lock(m_critSection);
488 m_strProgNow = Trim(strNow);
489 g_charsetConverter.unknownToUTF8(m_strProgNow);
490 }
491
492 void CPVRRadioRDSInfoTag::SetProgNext(const std::string& strNext)
493 {
494 std::unique_lock<CCriticalSection> lock(m_critSection);
495 m_strProgNext = Trim(strNext);
496 g_charsetConverter.unknownToUTF8(m_strProgNext);
497 }
498
499 void CPVRRadioRDSInfoTag::SetPhoneHotline(const std::string& strHotline)
500 {
501 std::unique_lock<CCriticalSection> lock(m_critSection);
502 m_strPhoneHotline = Trim(strHotline);
503 g_charsetConverter.unknownToUTF8(m_strPhoneHotline);
504 }
505
506 void CPVRRadioRDSInfoTag::SetEMailHotline(const std::string& strHotline)
507 {
508 std::unique_lock<CCriticalSection> lock(m_critSection);
509 m_strEMailHotline = Trim(strHotline);
510 g_charsetConverter.unknownToUTF8(m_strEMailHotline);
511 }
512
513 void CPVRRadioRDSInfoTag::SetPhoneStudio(const std::string& strPhone)
514 {
515 std::unique_lock<CCriticalSection> lock(m_critSection);
516 m_strPhoneStudio = Trim(strPhone);
517 g_charsetConverter.unknownToUTF8(m_strPhoneStudio);
518 }
519
520 void CPVRRadioRDSInfoTag::SetEMailStudio(const std::string& strEMail)
521 {
522 std::unique_lock<CCriticalSection> lock(m_critSection);
523 m_strEMailStudio = Trim(strEMail);
524 g_charsetConverter.unknownToUTF8(m_strEMailStudio);
525 }
526
527 void CPVRRadioRDSInfoTag::SetSMSStudio(const std::string& strSMS)
528 {
529 std::unique_lock<CCriticalSection> lock(m_critSection);
530 m_strSMSStudio = Trim(strSMS);
531 g_charsetConverter.unknownToUTF8(m_strSMSStudio);
532 }
533
534 const std::string& CPVRRadioRDSInfoTag::GetProgStyle() const
535 {
536 std::unique_lock<CCriticalSection> lock(m_critSection);
537 return m_strProgStyle;
538 }
539
540 const std::string& CPVRRadioRDSInfoTag::GetProgHost() const
541 {
542 std::unique_lock<CCriticalSection> lock(m_critSection);
543 return m_strProgHost;
544 }
545
546 const std::string& CPVRRadioRDSInfoTag::GetProgStation() const
547 {
548 std::unique_lock<CCriticalSection> lock(m_critSection);
549 return m_strProgStation;
550 }
551
552 const std::string& CPVRRadioRDSInfoTag::GetProgWebsite() const
553 {
554 std::unique_lock<CCriticalSection> lock(m_critSection);
555 return m_strProgWebsite;
556 }
557
558 const std::string& CPVRRadioRDSInfoTag::GetProgNow() const
559 {
560 std::unique_lock<CCriticalSection> lock(m_critSection);
561 return m_strProgNow;
562 }
563
564 const std::string& CPVRRadioRDSInfoTag::GetProgNext() const
565 {
566 std::unique_lock<CCriticalSection> lock(m_critSection);
567 return m_strProgNext;
568 }
569
570 const std::string& CPVRRadioRDSInfoTag::GetPhoneHotline() const
571 {
572 std::unique_lock<CCriticalSection> lock(m_critSection);
573 return m_strPhoneHotline;
574 }
575
576 const std::string& CPVRRadioRDSInfoTag::GetEMailHotline() const
577 {
578 std::unique_lock<CCriticalSection> lock(m_critSection);
579 return m_strEMailHotline;
580 }
581
582 const std::string& CPVRRadioRDSInfoTag::GetPhoneStudio() const
583 {
584 std::unique_lock<CCriticalSection> lock(m_critSection);
585 return m_strPhoneStudio;
586 }
587
588 const std::string& CPVRRadioRDSInfoTag::GetEMailStudio() const
589 {
590 std::unique_lock<CCriticalSection> lock(m_critSection);
591 return m_strEMailStudio;
592 }
593
594 const std::string& CPVRRadioRDSInfoTag::GetSMSStudio() const
595 {
596 std::unique_lock<CCriticalSection> lock(m_critSection);
597 return m_strSMSStudio;
598 }
599
600 void CPVRRadioRDSInfoTag::SetRadioStyle(const std::string& style)
601 {
602 std::unique_lock<CCriticalSection> lock(m_critSection);
603 m_strRadioStyle = style;
604 }
605
606 const std::string CPVRRadioRDSInfoTag::GetRadioStyle() const
607 {
608 std::unique_lock<CCriticalSection> lock(m_critSection);
609 return m_strRadioStyle;
610 }
611
612 void CPVRRadioRDSInfoTag::SetRadioText(const std::string& strRadioText)
613 {
614 std::unique_lock<CCriticalSection> lock(m_critSection);
615 m_strRadioText.Add(strRadioText);
616 }
617
618 std::string CPVRRadioRDSInfoTag::GetRadioText(unsigned int line) const
619 {
620 std::unique_lock<CCriticalSection> lock(m_critSection);
621
622 if (m_strRadioText.Size() > 0)
623 {
624 return m_strRadioText.GetLine(line);
625 }
626 else if (line == 0)
627 {
628 return m_strProgramServiceLine0;
629 }
630 else if (line == 1)
631 {
632 return m_strProgramServiceLine1;
633 }
634 return {};
635 }
636
637 void CPVRRadioRDSInfoTag::SetProgramServiceText(const std::string& strPSText)
638 {
639 std::unique_lock<CCriticalSection> lock(m_critSection);
640 m_strProgramServiceText.Add(strPSText);
641
642 m_strProgramServiceLine0.erase();
643 for (size_t i = m_strProgramServiceText.MaxSize() / 2 + 1; i < m_strProgramServiceText.MaxSize();
644 ++i)
645 {
646 m_strProgramServiceLine0 += m_strProgramServiceText.GetLine(i);
647 m_strProgramServiceLine0 += ' ';
648 }
649
650 m_strProgramServiceLine1.erase();
651 for (size_t i = 0; i < m_strProgramServiceText.MaxSize() / 2; ++i)
652 {
653 m_strProgramServiceLine1 += m_strProgramServiceText.GetLine(i);
654 m_strProgramServiceLine1 += ' ';
655 }
656 }
657
658 void CPVRRadioRDSInfoTag::SetPlayingRadioText(bool yesNo)
659 {
660 std::unique_lock<CCriticalSection> lock(m_critSection);
661 m_bHaveRadioText = yesNo;
662 }
663
664 bool CPVRRadioRDSInfoTag::IsPlayingRadioText() const
665 {
666 std::unique_lock<CCriticalSection> lock(m_critSection);
667 return m_bHaveRadioText;
668 }
669
670 void CPVRRadioRDSInfoTag::SetPlayingRadioTextPlus(bool yesNo)
671 {
672 std::unique_lock<CCriticalSection> lock(m_critSection);
673 m_bHaveRadioTextPlus = yesNo;
674 }
675
676 bool CPVRRadioRDSInfoTag::IsPlayingRadioTextPlus() const
677 {
678 std::unique_lock<CCriticalSection> lock(m_critSection);
679 return m_bHaveRadioTextPlus;
680 }
681
682 std::string CPVRRadioRDSInfoTag::Trim(const std::string& value)
683 {
684 std::string trimmedValue(value);
685 StringUtils::TrimLeft(trimmedValue);
686 StringUtils::TrimRight(trimmedValue, " \n\r");
687 return trimmedValue;
688 }
689
690 bool CPVRRadioRDSInfoTag::Info::operator==(const CPVRRadioRDSInfoTag::Info& right) const
691 {
692 if (this == &right)
693 return true;
694
695 return (m_infoText == right.m_infoText && m_data == right.m_data &&
696 m_maxSize == right.m_maxSize && m_prependData == right.m_prependData);
697 }
698
699 void CPVRRadioRDSInfoTag::Info::Clear()
700 {
701 m_data.clear();
702 m_infoText.clear();
703 }
704
705 void CPVRRadioRDSInfoTag::Info::Add(const std::string& text)
706 {
707 std::string tmp = Trim(text);
708 g_charsetConverter.unknownToUTF8(tmp);
709
710 if (std::find(m_data.begin(), m_data.end(), tmp) != m_data.end())
711 return;
712
713 if (m_data.size() >= m_maxSize)
714 {
715 if (m_prependData)
716 m_data.pop_back();
717 else
718 m_data.pop_front();
719 }
720
721 if (m_prependData)
722 m_data.emplace_front(std::move(tmp));
723 else
724 m_data.emplace_back(std::move(tmp));
725
726 m_infoText.clear();
727 for (const std::string& data : m_data)
728 {
729 m_infoText += data;
730 m_infoText += '\n';
731 }
732
733 // send a message to all windows to tell them to update the radiotext
734 CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_RADIOTEXT);
735 CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg);
736 }