Ticket #9740: mythtv-0.24-p2.patch
File mythtv-0.24-p2.patch, 12.8 KB (added by , 13 years ago) |
---|
-
mythtv/programs/mythwelcome/welcomedialog.cpp
diff --git a/mythtv/programs/mythwelcome/welcomedialog.cpp b/mythtv/programs/mythwelcome/welcomedialog.cpp index 743519e..bb107ae 100644
a b 1 1 // ANSI C 2 2 #include <cstdlib> 3 #include <fstream> 3 4 4 5 // POSIX 5 6 #include <unistd.h> … … 23 24 #include "welcomedialog.h" 24 25 #include "welcomesettings.h" 25 26 26 #define UPDATE_STATUS_INTERVAL 3000027 #define UPDATE_SCREEN_INTERVAL 1500027 #define UPDATE_STATUS_INTERVAL 30000 28 #define UPDATE_SCREEN_INTERVAL 15000 28 29 30 #define ACTION_CLOSE 1 31 #define ACTION_SHOW_WELCOME_SETTINGS 2 32 #define ACTION_SHOW_SHUTDOWN_SETTINGS 3 33 29 34 30 35 WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) 31 36 :MythScreenType(parent, name), … … WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) 49 54 m_timeFormat = gCoreContext->GetSetting("TimeFormat", "h:mm AP"); 50 55 m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat", "dddd\\ndd MMM yyyy"); 51 56 m_dateFormat.replace("\\n", "\n"); 57 m_closePasswordSetting = "MythWelcomeExitPIN"; 52 58 53 59 // if idleTimeoutSecs is 0, the user disabled the auto-shutdown feature 54 60 m_bWillShutdown = (gCoreContext->GetNumSetting("idleTimeoutSecs", 0) != 0); … … void WelcomeDialog::customEvent(QEvent *e) 212 218 } 213 219 } 214 220 221 void WelcomeDialog::showWelcomeSettings(void) 222 { 223 MythWelcomeSettings settings; 224 if (kDialogCodeAccepted == settings.exec()) 225 { 226 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 227 updateStatus(); 228 updateScreen(); 229 230 m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat", "dddd\\ndd MMM yyyy"); 231 m_dateFormat.replace("\\n", "\n"); 232 } 233 } 234 235 void WelcomeDialog::showShutdownSettings(void) 236 { 237 MythShutdownSettings settings; 238 if (kDialogCodeAccepted == settings.exec()) 239 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 240 } 241 215 242 bool WelcomeDialog::keyPressEvent(QKeyEvent *event) 216 243 { 217 244 if (GetFocusWidget()->keyPressEvent(event)) … … bool WelcomeDialog::keyPressEvent(QKeyEvent *event) 238 265 { 239 266 Close(); 240 267 } 241 else if ( action == "INFO")268 else if ( (action == "INFO") && checkPinCode("MythWelcome settings", ACTION_SHOW_WELCOME_SETTINGS) ) 242 269 { 243 MythWelcomeSettings settings; 244 if (kDialogCodeAccepted == settings.exec()) 245 { 246 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 247 updateStatus(); 248 updateScreen(); 249 250 m_dateFormat = gCoreContext->GetSetting("MythWelcomeDateFormat", "dddd\\ndd MMM yyyy"); 251 m_dateFormat.replace("\\n", "\n"); 252 } 270 showWelcomeSettings(); 253 271 } 254 else if ( action == "SHOWSETTINGS")272 else if ( (action == "SHOWSETTINGS") && checkPinCode("MythShutdown settings", ACTION_SHOW_SHUTDOWN_SETTINGS) ) 255 273 { 256 MythShutdownSettings settings; 257 if (kDialogCodeAccepted == settings.exec()) 258 RemoteSendMessage("CLEAR_SETTINGS_CACHE"); 274 showShutdownSettings(); 259 275 } 260 276 else if (action == "0") 261 277 { … … bool WelcomeDialog::keyPressEvent(QKeyEvent *event) 307 323 308 324 void WelcomeDialog::closeDialog() 309 325 { 326 if ( !checkPinCode("Exit PIN", ACTION_CLOSE) ) 327 { 328 // password dialog is created, checking will be done in closePasswordCheck function 329 // return without closing now 330 updateStatusMessage(); 331 updateScreen(); 332 return; 333 } 334 310 335 Close(); 311 336 } 312 337 … … void WelcomeDialog::showMenu(void) 614 639 615 640 m_menuPopup->AddButton(tr("Run mythfilldatabase"), SLOT(runEPGGrabber())); 616 641 m_menuPopup->AddButton(tr("Shutdown Now"), SLOT(shutdownNow())); 642 m_menuPopup->AddButton(tr("Reboot Now"), SLOT(rebootNow())); 617 643 m_menuPopup->AddButton(tr("Exit"), SLOT(closeDialog())); 618 644 m_menuPopup->AddButton(tr("Cancel")); 619 645 } … … void WelcomeDialog::runEPGGrabber(void) 642 668 updateScreen(); 643 669 } 644 670 645 void WelcomeDialog::shutdownNow( void)671 void WelcomeDialog::shutdownNow(bool is_poweroff) 646 672 { 673 // is_poweroff is true by default, so calling from shutdown menu it perform a real shutdown 674 // rebootNow function will call this function with false as parameter 675 QString poweroff_cmd = gCoreContext->GetSetting(is_poweroff ? "MythShutdownPowerOff" : "MythShutdownReboot", ""); 676 if ( poweroff_cmd.isEmpty() ) return; 677 647 678 // if this is a frontend only machine just shut down now 648 679 if (gCoreContext->IsFrontendOnly()) 649 680 { 650 VERBOSE(VB_GENERAL, "MythWelcome is shutting this computer down now");651 QString poweroff_cmd = gCoreContext->GetSetting("MythShutdownPowerOff", "");652 if (!poweroff_cmd.isEmpty())653 681 VERBOSE(VB_GENERAL, QString("MythWelcome is %1 this computer %2now") 682 .arg(is_poweroff ? "shutting" : "rebooting") 683 .arg(is_poweroff ? "down" : "")); 684 myth_system(poweroff_cmd); 654 685 return; 655 686 } 656 687 657 688 // don't shutdown if we are recording 658 689 if (m_isRecording) 659 690 { 660 MythPopupBox::showOkPopup(GetMythMainWindow(), "Cannot shutdown",661 tr("Cannot shutdown because MythTV is currently recording"));691 MythPopupBox::showOkPopup(GetMythMainWindow(), QString("Cannot %1").arg(is_poweroff ? "shutdown" : "reboot"), 692 QString("Cannot %1 because MythTV is currently recording").arg(is_poweroff ? "shutdown" : "reboot")); 662 693 return; 663 694 } 664 695 665 696 QDateTime curtime = QDateTime::currentDateTime(); 666 697 667 // don't shutdown if we are about to start recording698 // don't shutdown/reboot if we are about to start recording 668 699 if (!m_nextRecordingStart.isNull() && 669 700 curtime.secsTo(m_nextRecordingStart) - m_preRollSeconds < 670 701 (m_idleWaitForRecordingTime * 60) + m_idleTimeoutSecs) 671 702 { 672 MythPopupBox::showOkPopup(GetMythMainWindow(), "Cannot shutdown",673 tr("Cannot shutdown because MythTV is about to start recording"));703 MythPopupBox::showOkPopup(GetMythMainWindow(), QString("Cannot %1").arg(is_poweroff ? "shutdown" : "reboot"), 704 QString("Cannot %1 because MythTV is about to start recording").arg(is_poweroff ? "shutdown" : "reboot")); 674 705 return; 675 706 } 676 707 677 // don't shutdown if we are about to start a wakeup/shutdown period708 // don't shutdown/reboot if we are about to start a wakeup/shutdown period 678 709 QString mythshutdown_exe_status = 679 710 m_installDir + "/bin/mythshutdown --status 0"; 680 711 int statusCode = system(mythshutdown_exe_status.toLocal8Bit().constData()); … … void WelcomeDialog::shutdownNow(void) 683 714 684 715 if (statusCode & 128) 685 716 { 686 MythPopupBox::showOkPopup(GetMythMainWindow(), "Cannot shutdown", 687 tr("Cannot shutdown because MythTV is about to start " 688 "a wakeup/shutdown period.")); 717 MythPopupBox::showOkPopup(GetMythMainWindow(), QString("Cannot %1").arg(is_poweroff ? "shutdown" : "reboot"), 718 QString("Cannot %1 because MythTV is about to start a wakeup/shutdown period.").arg(is_poweroff ? "shutdown" : "reboot")); 689 719 return; 690 720 } 691 721 … … void WelcomeDialog::shutdownNow(void) 721 751 } 722 752 } 723 753 724 // run command to set wakeuptime in bios and shutdown the system 725 QString mythshutdown_exe = 726 "sudo " + m_installDir + "/bin/mythshutdown --shutdown"; 727 myth_system(mythshutdown_exe); 754 // run command to set wakeuptime in bios and shutdown/reboot the system 755 myth_system(poweroff_cmd); 756 } 757 758 void WelcomeDialog::rebootNow(void) 759 { 760 // run shutdown function with parameter false, so a reboot will be performed 761 shutdownNow(false); 762 } 763 764 bool WelcomeDialog::checkPinCode(const QString &title, uint action) 765 { 766 if ( gCoreContext->GetNumSetting(m_closePasswordSetting, 0) ) 767 { 768 QString password = gCoreContext->GetSetting(m_closePasswordSetting); 769 770 if (!password.isEmpty()) 771 { 772 // exit password is set, delay action until valid password is entered 773 VERBOSE(VB_GENERAL, QString("Using Password: %1").arg(m_closePasswordSetting)); 774 775 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 776 MythTextInputDialog *pwd = 777 new MythTextInputDialog(mainStack, title, FilterNone, true); 778 switch(action) 779 { 780 default: 781 case ACTION_CLOSE: 782 connect(pwd, SIGNAL(haveResult(QString)),SLOT(closePasswordCheck(QString))); 783 break; 784 case ACTION_SHOW_WELCOME_SETTINGS: 785 connect(pwd, SIGNAL(haveResult(QString)),SLOT(showWelcomeSettingsPasswordCheck(QString))); 786 break; 787 case ACTION_SHOW_SHUTDOWN_SETTINGS: 788 connect(pwd, SIGNAL(haveResult(QString)),SLOT(showShutdownSettingsPasswordCheck(QString))); 789 break; 790 } 791 if (pwd->Create()) 792 { 793 mainStack->AddScreen(pwd, false); 794 } 795 // password dialog is created, checking will be done in specified action function 796 updateStatusMessage(); 797 updateScreen(); 798 // return false, so no action will be done 799 return false; 800 } 801 } 802 return true; 803 } 804 805 void WelcomeDialog::closePasswordCheck(const QString &password) 806 { 807 QString exit_password = gCoreContext->GetSetting(m_closePasswordSetting); 808 VERBOSE(VB_GENERAL, QString("closePasswordCheck")); 809 810 if (exit_password == password) Close(); 811 } 812 813 void WelcomeDialog::showWelcomeSettingsPasswordCheck(const QString &password) 814 { 815 QString exit_password = gCoreContext->GetSetting(m_closePasswordSetting); 816 VERBOSE(VB_GENERAL, QString("showWelcomeSettingsPasswordCheck")); 817 818 if (exit_password == password) showWelcomeSettings(); 728 819 } 729 820 821 void WelcomeDialog::showShutdownSettingsPasswordCheck(const QString &password) 822 { 823 QString exit_password = gCoreContext->GetSetting(m_closePasswordSetting); 824 VERBOSE(VB_GENERAL, QString("showShutdownSettingsPasswordCheck")); 825 826 if (exit_password == password) showShutdownSettings(); 827 } -
mythtv/programs/mythwelcome/welcomedialog.h
diff --git a/mythtv/programs/mythwelcome/welcomedialog.h b/mythtv/programs/mythwelcome/welcomedialog.h index 1f16c59..c6a6b7a 100644
a b class WelcomeDialog : public MythScreenType 34 34 void updateScreen(void); 35 35 void closeDialog(void); 36 36 void showMenu(void); 37 void shutdownNow(void); 37 void shutdownNow(bool is_poweroff=true); 38 void rebootNow(void); 38 39 void runEPGGrabber(void); 39 40 void lockShutdown(void); 40 41 void unlockShutdown(void); 41 42 bool updateRecordingList(void); 42 43 bool updateScheduledList(void); 43 44 void showWelcomeSettings(void); 45 void showShutdownSettings(void); 46 bool checkPinCode(const QString &title, uint action); 47 void closePasswordCheck(const QString &password); 48 void showWelcomeSettingsPasswordCheck(const QString &password); 49 void showShutdownSettingsPasswordCheck(const QString &password); 50 44 51 private: 45 52 void updateStatusMessage(void); 46 53 bool checkConnectionToServer(void); … … class WelcomeDialog : public MythScreenType 78 85 uint m_statusListNo; 79 86 QStringList m_statusList; 80 87 bool m_frontendIsRunning; 88 QString m_closePasswordSetting; 81 89 82 90 vector<TunerStatus> m_tunerList; 83 91 ProgramDetailList m_scheduledList; -
mythtv/programs/mythwelcome/welcomesettings.cpp
diff --git a/mythtv/programs/mythwelcome/welcomesettings.cpp b/mythtv/programs/mythwelcome/welcomesettings.cpp index 39c85d2..7970018 100644
a b static HostLineEdit *MythWelcomeDateFormat() 85 85 return gc; 86 86 }; 87 87 88 88 89 MythWelcomeSettings::MythWelcomeSettings() 89 90 { 90 91 HorizontalConfigurationGroup* hcg1 = … … static HostLineEdit *MythShutdownXTermCmd() 196 197 return gc; 197 198 }; 198 199 200 static HostLineEdit *MythWelcomeExitPIN() 201 { 202 HostLineEdit *gc = new HostLineEdit("MythWelcomeExitPIN"); 203 gc->setLabel(QObject::tr("Exit PIN")); 204 gc->setValue(""); 205 gc->setHelpText(QObject::tr("Enter a PIN to protect MythWelcome from exit. " 206 "It also protect from accessing to setting screen. " 207 "Leave it blank to disable it. ")); 208 return gc; 209 }; 210 199 211 200 212 MythShutdownSettings::MythShutdownSettings() 201 213 { … … MythShutdownSettings::MythShutdownSettings() 210 222 vcg->addChild(MythShutdownPowerOff()); 211 223 vcg->addChild(MythShutdownXTermCmd()); 212 224 vcg->addChild(MythShutdownStartFECmd()); 225 vcg->addChild(MythWelcomeExitPIN()); 213 226 214 227 addChild(vcg); 215 228 }