/** \brief Queries the user for a password to enter a part of MythTV * restricted by a password. * * \param timestamp_setting time settings to be checked * \param password_setting password to be checked * \param text the message text to be displayed * \return true if password checks out or is not needed. */ bool MythThemedMenu::checkPinCode(const QString &password_setting) { QString timestamp_setting = QString("%1Time").arg(password_setting); QDateTime curr_time = MythDate::current(); QString last_time_stamp = GetMythDB()->GetSetting(timestamp_setting); QString password = GetMythDB()->GetSetting(password_setting); // Password empty? Then skip asking for it if (password.isEmpty()) return true; if (last_time_stamp.length() < 1) { LOG(VB_GENERAL, LOG_ERR, "MythThemedMenu: Could not read password/pin time stamp.\n" "This is only an issue if it happens repeatedly."); } else { QDateTime last_time = MythDate::fromString(last_time_stamp); if (!last_time.isValid() || last_time.secsTo(curr_time) < 120) { last_time_stamp = MythDate::toString( curr_time, MythDate::kDatabase); GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp); return true; } } LOG(VB_GENERAL, LOG_INFO, QString("Using Password: %1") .arg(password_setting)); QString text = tr("Enter password:"******"popup stack"); MythTextInputDialog *dialog = new MythTextInputDialog(popupStack, text, FilterNone, true); if (dialog->Create()) { dialog->SetReturnEvent(this, "password"); popupStack->AddScreen(dialog); } else delete dialog; return false; }
void BackendSelection::PromptForPassword(void) { QString message = tr("Please enter the backend access PIN"); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythTextInputDialog *pwDialog = new MythTextInputDialog(popupStack, message, FilterNone, true); if (pwDialog->Create()) { pwDialog->SetReturnEvent(this, "password"); popupStack->AddScreen(pwDialog); } else delete pwDialog; }
void IconView::HandleRename(void) { ThumbItem *thumbitem = GetCurrentThumb(); if (!thumbitem) return; QString folderName = thumbitem->GetName(); QString message = tr("Rename"); MythTextInputDialog *dialog = new MythTextInputDialog(m_popupStack, message, FilterNone, false, folderName); if (dialog->Create()) m_popupStack->AddScreen(dialog); connect(dialog, SIGNAL(haveResult(QString)), SLOT(DoRename(QString)), Qt::QueuedConnection); }
// returns true if no completion is required bool DoCheck() { ParentalLevel which_level(m_toLevel); // No password for level 1 and you can always switch down from your // current level. if (which_level == ParentalLevel::plLowest || which_level <= ParentalLevel(m_fromLevel)) return true; // If there isn't a password at the current level, and // none of the levels below, we are done. // The assumption is that if you password protected lower levels, // and a higher level does not have a password it is something // you've overlooked (rather than intended). if (!m_pm.FirstAtOrBelow(which_level.GetLevel()).length()) return true; // See if we recently (and successfully) asked for a password QString last_time_stamp = gCoreContext->GetSetting("VideoPasswordTime"); int last_parent_lvl = gCoreContext->GetNumSetting("VideoPasswordLevel", -1); if (!last_time_stamp.length() || last_parent_lvl == -1) { VERBOSE(VB_IMPORTANT, QString("%1: Could not read password/pin time " "stamp. This is only an issue if it " "happens repeatedly.").arg(__FILE__)); } else { QDateTime curr_time = QDateTime::currentDateTime(); QDateTime last_time = QDateTime::fromString(last_time_stamp, Qt::ISODate); if (ParentalLevel(last_parent_lvl) >= which_level && last_time.secsTo(curr_time) < 120) { // Two minute window last_time_stamp = curr_time.toString(Qt::ISODate); gCoreContext->SetSetting("VideoPasswordTime", last_time_stamp); gCoreContext->SaveSetting("VideoPasswordTime", last_time_stamp); return true; } } m_validPasswords = m_pm.AtOrAbove(which_level.GetLevel()); // If there isn't a password for this level or higher levels, treat // the next lower password as valid. This is only done so people // cannot lock themselves out of the setup. if (!m_validPasswords.size()) { QString pw = m_pm.FirstAtOrBelow(which_level.GetLevel()); if (pw.length()) m_validPasswords.push_back(pw); } // There are no suitable passwords. if (!m_validPasswords.size()) return true; // If we got here, there is a password, and there's no backing down. MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythTextInputDialog *pwd = new MythTextInputDialog(popupStack, QObject::tr("Parental PIN:"), FilterNone, true); connect(pwd, SIGNAL(haveResult(QString)), SLOT(OnPasswordEntered(QString))); connect(pwd, SIGNAL(Exiting()), SLOT(OnPasswordExit())); if (pwd->Create()) popupStack->AddScreen(pwd, false); return false; }
void ProgramRecPriority::customEvent(QEvent *event) { if (event->type() == DialogCompletionEvent::kEventType) { DialogCompletionEvent *dce = (DialogCompletionEvent*)(event); QString resultid = dce->GetId(); QString resulttext = dce->GetResultText(); int buttonnum = dce->GetResult(); if (resultid == "menu") { if (resulttext == tr("Increase Priority")) { changeRecPriority(1); } else if (resulttext == tr("Decrease Priority")) { changeRecPriority(-1); } else if (resulttext == tr("Sort")) { showSortMenu(); } else if (resulttext == tr("Program Details")) { ShowDetails(); } else if (resulttext == tr("Upcoming")) { saveRecPriority(); ShowUpcoming(); } else if (resulttext == tr("Custom Edit")) { saveRecPriority(); EditCustom(); } else if (resulttext == tr("Delete Rule")) { saveRecPriority(); remove(); } else if (resulttext == tr("New Template")) { MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythTextInputDialog *textInput = new MythTextInputDialog(popupStack, tr("Template Name")); if (textInput->Create()) { textInput->SetReturnEvent(this, "templatecat"); popupStack->AddScreen(textInput); } } } else if (resultid == "sortmenu") { if (resulttext == tr("Reverse Sort Order")) { m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Title")) { if (m_sortType != byTitle) { m_sortType = byTitle; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Priority")) { if (m_sortType != byRecPriority) { m_sortType = byRecPriority; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Type")) { if (m_sortType != byRecType) { m_sortType = byRecType; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Count")) { if (m_sortType != byCount) { m_sortType = byCount; m_reverseSort = false; } else { m_reverseSort = !m_reverseSort; } SortList(); } else if (resulttext == tr("Sort By Record Count")) { if (m_sortType != byRecCount) { m_sortType = byRecCount; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Last Recorded")) { if (m_sortType != byLastRecord) { m_sortType = byLastRecord; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } else if (resulttext == tr("Sort By Average Delay")) { if (m_sortType != byAvgDelay) { m_sortType = byAvgDelay; m_reverseSort = false; } else m_reverseSort = !m_reverseSort; SortList(); } } else if (resultid == "deleterule") { RecordingRule *record = dce->GetData().value<RecordingRule *>(); if (record) { if (buttonnum > 0) { MythUIButtonListItem *item = m_programList->GetItemCurrent(); if (record->Delete() && item) RemoveItemFromList(item); else LOG(VB_GENERAL, LOG_ERR, "Failed to delete recording rule"); } delete record; } } else if (resultid == "templatecat") { newTemplate(resulttext); } else ScheduleCommon::customEvent(event); } }