2 * Copyright (C) 2016-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 "PVRGUIActionsParentalControl.h"
11 #include "ServiceBroker.h"
12 #include "dialogs/GUIDialogNumeric.h"
13 #include "guilib/LocalizeStrings.h"
14 #include "messaging/helpers/DialogOKHelper.h"
15 #include "pvr/PVRManager.h"
16 #include "pvr/channels/PVRChannel.h"
17 #include "settings/Settings.h"
18 #include "utils/Variant.h"
19 #include "utils/log.h"
25 using namespace KODI::MESSAGING
;
27 CPVRGUIActionsParentalControl::CPVRGUIActionsParentalControl()
28 : m_settings({CSettings::SETTING_PVRPARENTAL_PIN
, CSettings::SETTING_PVRPARENTAL_ENABLED
})
32 ParentalCheckResult
CPVRGUIActionsParentalControl::CheckParentalLock(
33 const std::shared_ptr
<const CPVRChannel
>& channel
) const
35 if (!CServiceBroker::GetPVRManager().IsParentalLocked(channel
))
36 return ParentalCheckResult::SUCCESS
;
38 ParentalCheckResult ret
= CheckParentalPIN();
40 if (ret
== ParentalCheckResult::FAILED
)
41 CLog::LogF(LOGERROR
, "Parental lock verification failed for channel '{}': wrong PIN entered.",
42 channel
->ChannelName());
47 ParentalCheckResult
CPVRGUIActionsParentalControl::CheckParentalPIN() const
49 if (!m_settings
.GetBoolValue(CSettings::SETTING_PVRPARENTAL_ENABLED
))
50 return ParentalCheckResult::SUCCESS
;
52 std::string pinCode
= m_settings
.GetStringValue(CSettings::SETTING_PVRPARENTAL_PIN
);
54 return ParentalCheckResult::SUCCESS
;
56 InputVerificationResult ret
= CGUIDialogNumeric::ShowAndVerifyInput(
57 pinCode
, g_localizeStrings
.Get(19262), true); // "Parental control. Enter PIN:"
59 if (ret
== InputVerificationResult::SUCCESS
)
61 CServiceBroker::GetPVRManager().RestartParentalTimer();
62 return ParentalCheckResult::SUCCESS
;
64 else if (ret
== InputVerificationResult::FAILED
)
66 HELPERS::ShowOKDialogText(CVariant
{19264},
67 CVariant
{19265}); // "Incorrect PIN", "The entered PIN was incorrect."
68 return ParentalCheckResult::FAILED
;
72 return ParentalCheckResult::CANCELED
;