Пример #1
0
// \brief Show numeric keypad and verify user input against strToVerify.
// \param strToVerify Value to compare against user input.
// \param dlgHeading String shown on dialog title.
// \param bVerifyInput If set as true we verify the users input versus strToVerify.
// \return the result of the check (success, failed, or canceled by user).
InputVerificationResult CGUIDialogNumeric::ShowAndVerifyInput(std::string& strToVerify, const std::string& dlgHeading, bool bVerifyInput)
{
  // Prompt user for password input
  CGUIDialogNumeric *pDialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogNumeric>(WINDOW_DIALOG_NUMERIC);
  pDialog->SetHeading(dlgHeading);

  std::string strInput;
  if (!bVerifyInput)
    strInput = strToVerify;

  pDialog->SetMode(INPUT_PASSWORD, strInput);
  pDialog->Open();

  strInput = pDialog->GetOutputString();

  if (!pDialog->IsConfirmed() || pDialog->IsCanceled())
  {
    // user canceled out
    strToVerify = "";
    return InputVerificationResult::CANCELED;
  }

  const std::string md5pword2 = CDigest::Calculate(CDigest::Type::MD5, strInput);

  if (!bVerifyInput)
  {
    strToVerify = md5pword2;
    return InputVerificationResult::SUCCESS;
  }

  return StringUtils::EqualsNoCase(strToVerify, md5pword2) ? InputVerificationResult::SUCCESS : InputVerificationResult::FAILED;
}
Пример #2
0
bool CGUIDialogNumeric::ShowAndGetIPAddress(std::string &IPAddress, const std::string &heading)
{
  CGUIDialogNumeric *pDialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogNumeric>(WINDOW_DIALOG_NUMERIC);
  if (!pDialog) return false;
  pDialog->SetMode(INPUT_IP_ADDRESS, IPAddress);
  pDialog->SetHeading(heading);
  pDialog->Open();
  if (!pDialog->IsConfirmed() || pDialog->IsCanceled())
    return false;
  IPAddress = pDialog->GetOutputString();
  return true;
}
Пример #3
0
bool CGUIDialogNumeric::ShowAndGetNumber(std::string& strInput, const std::string &strHeading, unsigned int iAutoCloseTimeoutMs /* = 0 */)
{
  // Prompt user for password input
  CGUIDialogNumeric *pDialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogNumeric>(WINDOW_DIALOG_NUMERIC);
  pDialog->SetHeading( strHeading );

  pDialog->SetMode(INPUT_NUMBER, strInput);
  if (iAutoCloseTimeoutMs)
    pDialog->SetAutoClose(iAutoCloseTimeoutMs);

  pDialog->Open();

  if (!pDialog->IsAutoClosed() && (!pDialog->IsConfirmed() || pDialog->IsCanceled()))
    return false;
  strInput = pDialog->GetOutputString();
  return true;
}
Пример #4
0
// \brief Show numeric keypad and verify user input against strToVerify.
// \param strToVerify Value to compare against user input.
// \param dlgHeading String shown on dialog title.
// \param bVerifyInput If set as true we verify the users input versus strToVerify.
// \return true if successful display and user input. false if unsuccessful display, no user input, or canceled editing.
bool CGUIDialogNumeric::ShowAndVerifyInput(std::string& strToVerify, const std::string& dlgHeading, bool bVerifyInput)
{
  // Prompt user for password input
  CGUIDialogNumeric *pDialog = (CGUIDialogNumeric *)g_windowManager.GetWindow(WINDOW_DIALOG_NUMERIC);
  pDialog->SetHeading( dlgHeading );

  std::string strInput;
  if (!bVerifyInput)
    strInput = strToVerify;
  pDialog->SetMode(INPUT_PASSWORD, strInput);
  pDialog->Open();

  strInput = pDialog->GetOutputString();

  if (!pDialog->IsConfirmed() || pDialog->IsCanceled())
  {
    // user canceled out
    strToVerify ="";
    return false;
  }

  std::string md5pword2 = XBMC::XBMC_MD5::GetMD5(strInput);

  if (!bVerifyInput)
  {
    strToVerify = md5pword2;
    StringUtils::ToLower(strToVerify);
    return true;
  }

  if (StringUtils::EqualsNoCase(strToVerify, md5pword2))
    return true;  // entered correct password

  // incorrect password
  return false;
}