| 316 | bool WelcomeDialog::checkPinCode(const QString ×tamp_setting, |
| 317 | const QString &password_setting, |
| 318 | const QString &text) |
| 319 | { |
| 320 | QDateTime curr_time = QDateTime::currentDateTime(); |
| 321 | QString last_time_stamp = gContext->GetSetting(timestamp_setting); |
| 322 | QString password = gContext->GetSetting(password_setting); |
| 323 | |
| 324 | if (password.length() < 1) |
| 325 | return true; |
| 326 | |
| 327 | if (last_time_stamp.length() < 1) |
| 328 | { |
| 329 | VERBOSE(VB_IMPORTANT, |
| 330 | "MythThemedMenuPrivate: Could not read password/pin time stamp.\n" |
| 331 | "This is only an issue if it happens repeatedly."); |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | QDateTime last_time = QDateTime::fromString(last_time_stamp, |
| 336 | Qt::TextDate); |
| 337 | if (last_time.secsTo(curr_time) < 120) |
| 338 | { |
| 339 | last_time_stamp = curr_time.toString(Qt::TextDate); |
| 340 | gContext->SetSetting(timestamp_setting, last_time_stamp); |
| 341 | gContext->SaveSetting(timestamp_setting, last_time_stamp); |
| 342 | return true; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | if (password.length() > 0) |
| 347 | { |
| 348 | bool ok = false; |
| 349 | MythPasswordDialog *pwd = new MythPasswordDialog(text, &ok, password, |
| 350 | gContext->GetMainWindow()); |
| 351 | pwd->exec(); |
| 352 | pwd->deleteLater(); |
| 353 | |
| 354 | if (ok) |
| 355 | { |
| 356 | last_time_stamp = curr_time.toString(Qt::TextDate); |
| 357 | gContext->SetSetting(timestamp_setting, last_time_stamp); |
| 358 | gContext->SaveSetting(timestamp_setting, last_time_stamp); |
| 359 | return true; |
| 360 | } |
| 361 | } |
| 362 | else |
| 363 | { |
| 364 | return true; |
| 365 | } |
| 366 | |
| 367 | return false; |
| 368 | } |
| 369 | |
| 872 | void WelcomeDialog::rebootNow(void) |
| 873 | { |
| 874 | QString reboot_cmd = gContext->GetSetting("MythShutdownReboot", ""); |
| 875 | cancelPopup(); |
| 876 | |
| 877 | // if this is a frontend only machine just shut down now |
| 878 | if (gContext->IsFrontendOnly()) |
| 879 | { |
| 880 | VERBOSE(VB_GENERAL, "MythWelcome is rebooting this computer down now"); |
| 881 | if (reboot_cmd != "") system(reboot_cmd.ascii()); |
| 882 | return; |
| 883 | } |
| 884 | |
| 885 | // don't shutdown if we are recording |
| 886 | if (m_isRecording) |
| 887 | { |
| 888 | MythPopupBox::showOkPopup(gContext->GetMainWindow(), "Cannot shutdown", |
| 889 | tr("Cannot shutdown because MythTV is currently recording")); |
| 890 | return; |
| 891 | } |
| 892 | |
| 893 | QDateTime curtime = QDateTime::currentDateTime(); |
| 894 | |
| 895 | // don't shutdown if we are about to start recording |
| 896 | if (!m_nextRecordingStart.isNull() && |
| 897 | curtime.secsTo(m_nextRecordingStart) - |
| 898 | m_preRollSeconds < m_idleWaitForRecordingTime * 60) |
| 899 | { |
| 900 | MythPopupBox::showOkPopup(gContext->GetMainWindow(), "Cannot shutdown", |
| 901 | tr("Cannot shutdown because MythTV is about to start recording")); |
| 902 | return; |
| 903 | } |
| 904 | |
| 905 | // run command to reboot the system |
| 906 | if (reboot_cmd != "") system(reboot_cmd.ascii()); |
| 907 | } |
| 908 | |