-
Notifications
You must be signed in to change notification settings - Fork 55
/
ChannelGroup.cpp
60 lines (48 loc) · 2.11 KB
/
ChannelGroup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "ChannelGroup.h"
#include "inttypes.h"
#include "util/XMLUtils.h"
#include "p8-platform/util/StringUtils.h"
using namespace enigma2;
using namespace enigma2::data;
using namespace enigma2::utilities;
bool ChannelGroup::UpdateFrom(TiXmlElement* groupNode, bool radio)
{
std::string serviceReference;
std::string groupName;
if (!XMLUtils::GetString(groupNode, "e2servicereference", serviceReference))
return false;
// Check whether the current element is not just a label
if (serviceReference.compare(0, 5, "1:64:") == 0)
return false;
if (!XMLUtils::GetString(groupNode, "e2servicename", groupName))
return false;
// Check if the current element is hidden, a separator or last scanned
if (groupName == "<n/a>" || StringUtils::EndsWith(groupName.c_str(), " - Separator") || groupName == "Last Scanned")
return false;
if (!radio && Settings::GetInstance().GetTVChannelGroupMode() == ChannelGroupMode::ONLY_ONE_GROUP &&
Settings::GetInstance().GetOneTVGroupName() != groupName)
{
Logger::Log(LEVEL_DEBUG, "%s Only one TV group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, serviceReference.c_str(), Settings::GetInstance().GetOneTVGroupName().c_str());
return false;
}
else if (radio && Settings::GetInstance().GetRadioChannelGroupMode() == ChannelGroupMode::ONLY_ONE_GROUP &&
Settings::GetInstance().GetOneRadioGroupName() != groupName)
{
Logger::Log(LEVEL_DEBUG, "%s Only one Radio group is set, but current e2servicename '%s' does not match requested name '%s'", __FUNCTION__, serviceReference.c_str(), Settings::GetInstance().GetOneRadioGroupName().c_str());
return false;
}
m_serviceReference = serviceReference;
m_groupName = groupName;
m_radio = radio;
return true;
}
void ChannelGroup::UpdateTo(PVR_CHANNEL_GROUP &left) const
{
left.bIsRadio = m_radio;
left.iPosition = 0; // groups default order, unused
strncpy(left.strGroupName, m_groupName.c_str(), sizeof(left.strGroupName));
}
void ChannelGroup::AddChannel(std::shared_ptr<Channel> channel)
{
m_channelList.emplace_back(channel);
}