2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "PVRClientCapabilities.h"
11 #include "guilib/LocalizeStrings.h"
12 #include "utils/StringUtils.h"
20 CPVRClientCapabilities::CPVRClientCapabilities(const CPVRClientCapabilities
& other
)
22 if (other
.m_addonCapabilities
)
23 m_addonCapabilities
= std::make_unique
<PVR_ADDON_CAPABILITIES
>(*other
.m_addonCapabilities
);
24 InitRecordingsLifetimeValues();
27 const CPVRClientCapabilities
& CPVRClientCapabilities::operator=(const CPVRClientCapabilities
& other
)
29 if (other
.m_addonCapabilities
)
30 m_addonCapabilities
= std::make_unique
<PVR_ADDON_CAPABILITIES
>(*other
.m_addonCapabilities
);
31 InitRecordingsLifetimeValues();
35 const CPVRClientCapabilities
& CPVRClientCapabilities::operator=(
36 const PVR_ADDON_CAPABILITIES
& addonCapabilities
)
38 m_addonCapabilities
= std::make_unique
<PVR_ADDON_CAPABILITIES
>(addonCapabilities
);
39 InitRecordingsLifetimeValues();
43 void CPVRClientCapabilities::clear()
45 m_recordingsLifetimeValues
.clear();
46 m_addonCapabilities
.reset();
49 void CPVRClientCapabilities::InitRecordingsLifetimeValues()
51 m_recordingsLifetimeValues
.clear();
52 if (m_addonCapabilities
&& m_addonCapabilities
->iRecordingsLifetimesSize
> 0)
54 for (unsigned int i
= 0; i
< m_addonCapabilities
->iRecordingsLifetimesSize
; ++i
)
56 const auto& lifetime
{m_addonCapabilities
->recordingsLifetimeValues
[i
]};
57 const int iValue
{lifetime
.iValue
};
58 std::string description
{lifetime
.strDescription
? lifetime
.strDescription
: ""};
59 if (description
.empty())
61 // No description given by addon. Create one from value.
62 description
= std::to_string(iValue
);
64 m_recordingsLifetimeValues
.emplace_back(description
, iValue
);
67 else if (SupportsRecordingsLifetimeChange())
69 // No values given by addon, but lifetime supported. Use default values 1..365
70 for (int i
= 1; i
< 366; ++i
)
72 m_recordingsLifetimeValues
.emplace_back(StringUtils::Format(g_localizeStrings
.Get(17999), i
),
78 // No lifetime supported.
82 void CPVRClientCapabilities::GetRecordingsLifetimeValues(
83 std::vector
<std::pair
<std::string
, int>>& list
) const
85 std::copy(m_recordingsLifetimeValues
.cbegin(), m_recordingsLifetimeValues
.cend(),
86 std::back_inserter(list
));