示例#1
0
bool CGUIDialogNumeric::ShowAndGetSeconds(std::string &timeString, const std::string &heading)
{
  CGUIDialogNumeric *pDialog = (CGUIDialogNumeric *)g_windowManager.GetWindow(WINDOW_DIALOG_NUMERIC);
  if (!pDialog) return false;
  int seconds = StringUtils::TimeStringToSeconds(timeString);
  SYSTEMTIME time = {0};
  time.wHour = seconds / 3600;
  time.wMinute = (seconds - time.wHour * 3600) / 60;
  time.wSecond = seconds - time.wHour * 3600 - time.wMinute * 60;
  pDialog->SetMode(INPUT_TIME_SECONDS, (void *)&time);
  pDialog->SetHeading(heading);
  pDialog->Open();
  if (!pDialog->IsConfirmed() || pDialog->IsCanceled())
    return false;
  pDialog->GetOutput(&time);
  seconds = time.wHour * 3600 + time.wMinute * 60 + time.wSecond;
  timeString = StringUtils::SecondsToTimeString(seconds);
  return true;
}
示例#2
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, (void *)&strInput);
  pDialog->Open();

  pDialog->GetOutput(&strInput);

  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;
}