2 * Copyright (C) 2005-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.
11 #include "guilib/GUIDialog.h"
12 #include "utils/XTimeUtils.h"
16 enum class InputVerificationResult
23 class CGUIDialogNumeric
:
27 enum INPUT_MODE
{ INPUT_TIME
= 1, INPUT_DATE
, INPUT_IP_ADDRESS
, INPUT_PASSWORD
, INPUT_NUMBER
, INPUT_TIME_SECONDS
};
28 CGUIDialogNumeric(void);
29 ~CGUIDialogNumeric(void) override
;
30 bool OnMessage(CGUIMessage
& message
) override
;
31 bool OnAction(const CAction
&action
) override
;
32 bool OnBack(int actionID
) override
;
33 void FrameMove() override
;
35 bool IsConfirmed() const;
36 bool IsCanceled() const;
37 bool IsInputHidden() const { return m_mode
== INPUT_PASSWORD
; }
39 static bool ShowAndVerifyNewPassword(std::string
& strNewPassword
);
40 static int ShowAndVerifyPassword(std::string
& strPassword
, const std::string
& strHeading
, int iRetries
);
41 static InputVerificationResult
ShowAndVerifyInput(std::string
& strPassword
, const std::string
& strHeading
, bool bGetUserInput
);
43 void SetHeading(const std::string
&strHeading
);
44 void SetMode(INPUT_MODE mode
, const KODI::TIME::SystemTime
& initial
);
45 void SetMode(INPUT_MODE mode
, const std::string
&initial
);
46 KODI::TIME::SystemTime
GetOutput() const;
47 std::string
GetOutputString() const;
49 static bool ShowAndGetTime(KODI::TIME::SystemTime
& time
, const std::string
& heading
);
50 static bool ShowAndGetDate(KODI::TIME::SystemTime
& date
, const std::string
& heading
);
51 static bool ShowAndGetIPAddress(std::string
&IPAddress
, const std::string
&heading
);
52 static bool ShowAndGetNumber(std::string
& strInput
, const std::string
&strHeading
, unsigned int iAutoCloseTimeoutMs
= 0, bool bSetHidden
= false);
53 static bool ShowAndGetSeconds(std::string
& timeString
, const std::string
&heading
);
56 void OnInitWindow() override
;
57 void OnDeinitWindow(int nextWindowID
) override
;
59 void OnNumber(uint32_t num
);
60 void VerifyDate(bool checkYear
);
67 void HandleInputIP(uint32_t num
);
68 void HandleInputDate(uint32_t num
);
69 void HandleInputSeconds(uint32_t num
);
70 void HandleInputTime(uint32_t num
);
72 bool m_bConfirmed
= false;
73 bool m_bCanceled
= false;
75 INPUT_MODE m_mode
= INPUT_PASSWORD
; // the current input mode
76 KODI::TIME::SystemTime m_datetime
; // for time and date modes
77 uint8_t m_ip
[4]; // for ip address mode
78 uint32_t m_block
{}; // for time, date, and IP methods.
79 uint32_t m_lastblock
{};
80 bool m_dirty
= false; // true if the current block has been changed.
81 std::string m_number
; ///< for number or password input