1#include "libmythbase/mythconfig.h"
14#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
15#include <QtEnvironmentVariables>
16#include <QtSystemDetection>
19#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
20#include <QtAndroidExtras>
22#include <QCoreApplication>
24#define QAndroidJniObject QJniObject
29#include <QApplication>
37#include <QProcessEnvironment>
41#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
42#include <QtWebEngineQuick>
68#include "libmythbase/mythversion.h"
139#include <QScopedPointer>
142#if CONFIG_SYSTEMD_NOTIFY
143#include <systemd/sd-daemon.h>
144static inline void fe_sd_notify(
const char *str) { sd_notify(0, str); };
167static bool gLoaded =
false;
170static const QString
sLocation = QCoreApplication::translate(
"(Common)",
191 this, &RunSettingsCompletion::OnPasswordResultReady);
226 LOG(VB_GENERAL, LOG_WARNING,
227 "Aggressive Parental Controls Warning: "
228 "invalid password. An attempt to enter a "
229 "MythVideo settings screen was prevented.");
248 bool bookmarkPresent,
bool lastPlayPresent) :
251 m_bookmarked(bookmarkPresent),
252 m_lastPlayed(lastPlayPresent),
253 m_btnPlayBookmark(tr(
"Play from bookmark")),
254 m_btnClearBookmark(tr(
"Clear bookmark")),
255 m_btnPlayBegin(tr(
"Play from beginning")),
256 m_btnPlayLast(tr(
"Play from last played position")),
257 m_btnClearLast(tr(
"Clear last played position")) {
262 QString msg = tr(
"DVD/Video contains a bookmark");
264 m_videoDlg =
dynamic_cast<VideoDialog*
>(GetScreenStack()->GetTopScreen());
265 auto *popup =
new MythDialogBox(msg, GetScreenStack(),
"bookmarkdialog");
266 if (!popup->Create())
272 GetScreenStack()->AddScreen(popup);
274 popup->SetReturnEvent(
this,
"bookmarkdialog");
276 popup->AddButton(m_btnPlayLast);
278 popup->AddButton(m_btnPlayBookmark);
279 popup->AddButton(m_btnPlayBegin);
281 popup->AddButton(m_btnClearLast);
283 popup->AddButton(m_btnClearBookmark);
294 QString buttonText = dce->GetResultText();
296 if (dce->GetId() !=
"bookmarkdialog")
299 if (buttonText == m_btnPlayLast)
303 else if (buttonText == m_btnPlayBookmark)
307 else if (buttonText == m_btnPlayBegin)
311 else if (buttonText == m_btnClearBookmark)
313 m_pgi->SaveBookmark(0);
316 m_videoDlg->playbackStateChanged(m_pgi->GetBasename());
319 else if (buttonText == m_btnClearLast)
321 m_pgi->SaveLastPlayPos(0);
324 m_videoDlg->playbackStateChanged(m_pgi->GetBasename());
332 bool m_bookmarked {
false};
333 bool m_lastPlayed {
false};
344 QCoreApplication::processEvents();
355 LOG(VB_GENERAL, LOG_INFO,
"Shutting down UPnP client...");
388 ShowOkPopup(QCoreApplication::translate(
"(MythFrontendMain)",
389 "The ScreenSetupWizard cannot be used while "
390 "mythfrontend is operating in windowed mode."));
427 auto *mythcontrols =
new MythControls(mainStack,
"mythcontrols");
429 if (mythcontrols->Create())
554 if (viewsched->Create())
566 if (progRecPrior->Create())
578 if (chanRecPrior->Create())
590 if (custom->Create())
600 auto *pbb =
new PlaybackBox(mainStack,
"playbackbox");
604 if (!recGroup.isEmpty())
605 pbb->setInitialRecGroup(recGroup);
645 if (custom->Create())
657 if (mansched->Create())
668 QString msg = QCoreApplication::translate(
"(Common)",
"All tuners are currently busy.");
671 msg = QCoreApplication::translate(
"(Common)",
"There are no configured tuners.");
686 while (keylist.size() < 2)
709 auto *statusbox =
new StatusBox(mainStack);
711 if (statusbox->Create())
724 if (idlescreen->Create())
732 QString message = QCoreApplication::translate(
"(MythFrontendMain)",
733 "Loading videos ...");
739 "mythvideobusydialog");
741 if (busyPopup->Create())
753 video_list = saved->GetSaved();
754 LOG(VB_GENERAL, LOG_INFO,
755 QString(
"Reusing saved video list because MythVideo was resumed"
770 if (mythvideo->Create())
791 if (galleryView->Create())
794 galleryView->Start();
805 LOG(VB_MEDIA, LOG_DEBUG,
"Checking for BluRay medium");
806 const QString bluray_mountpoint =
808 QDir bdtest(bluray_mountpoint +
"/BDMV");
814 QString
filename = QString(
"bd:/%1").arg(bluray_mountpoint);
817 0, 0,
"", 0min,
"",
"",
true);
826 LOG(VB_MEDIA, LOG_ERR,
"Could not access media monitor");
831 LOG(VB_MEDIA, LOG_DEBUG,
"Checking for DVD medium");
832 const bool isDVD = mediaMonitor->
IsActive()
839 if (dvd_device.isEmpty())
845 QString command_string =
847 if ((command_string.indexOf(
"internal", 0, Qt::CaseInsensitive) > -1) ||
848 (command_string.length() < 1))
853#elif defined(Q_OS_WINDOWS)
860 command_string =
"Internal";
862 "",
"", 0, 0,
"", 0min,
"",
"",
true);
868 if (command_string.contains(
"%d"))
873 command_string = command_string.replace(
"%d", dvd_device);
890 LOG(VB_MEDIA, LOG_DEBUG,
"Checking for audio CD medium");
894 if (!audioMedia.isEmpty())
896 for (
auto *medium : std::as_const(audioMedia))
898 if (medium->isUsable()) {
899 LOG(VB_MEDIA, LOG_DEBUG, QString(
"Found usable audio/mixed device %1").arg(medium->getDevicePath()));
928 LOG(VB_GENERAL, LOG_ERR,
929 "mythdvd main.o: handleMedia() does not know what to do");
941 QVector<MythScreenType*> screens;
945 for (
const auto *screen : std::as_const(screens))
947 if (qobject_cast<const GalleryThumbView*>(screen))
950 LOG(VB_MEDIA, LOG_INFO,
"Main: Ignoring new gallery media - already running");
957 LOG(VB_GUI, LOG_INFO,
"Main: Autostarting Gallery for new media");
962 LOG(VB_MEDIA, LOG_INFO,
"Main: Ignoring new gallery media - autorun not set");
968 QString sel = selection.toLower();
970 if (sel.startsWith(
"settings ") || sel ==
"video_settings_general")
978 if (sel ==
"tv_watch_live")
982 else if (sel.startsWith(
"tv_watch_recording"))
985 if ((selection.length() > 19) && (selection.mid(18, 1) ==
" "))
990 else if (sel ==
"tv_schedule")
994 else if (sel ==
"tv_manualschedule")
998 else if (sel ==
"tv_custom_record")
1002 else if (sel ==
"tv_fix_conflicts")
1006 else if (sel ==
"tv_manage_recording_rules")
1010 else if (sel ==
"tv_progfind")
1014 else if (sel ==
"tv_search_title")
1018 else if (sel ==
"tv_search_keyword")
1022 else if (sel ==
"tv_search_people")
1026 else if (sel ==
"tv_search_power")
1030 else if (sel ==
"tv_search_stored")
1034 else if (sel ==
"tv_search_channel")
1038 else if (sel ==
"tv_search_category")
1042 else if (sel ==
"tv_search_movie")
1046 else if (sel ==
"tv_search_new")
1050 else if (sel ==
"tv_search_time")
1054 else if (sel ==
"tv_previous")
1058 else if (sel ==
"tv_previous_old")
1062 else if (sel ==
"settings appearance")
1077 else if (sel ==
"settings themechooser")
1087 else if (sel ==
"settings setupwizard")
1097 else if (sel ==
"settings grabbers")
1107 else if (sel ==
"screensetupwizard")
1111 else if (sel ==
"setup_keys")
1115 else if (sel ==
"settings playgroup")
1130 else if (sel ==
"settings general")
1145 else if (sel ==
"settings audiogeneral")
1161 else if (sel ==
"settings maingeneral")
1176 else if (sel ==
"settings playback")
1191 else if (sel ==
"settings osd")
1206 else if (sel ==
"settings epg")
1221 else if (sel ==
"settings channelgroups")
1236 else if (sel ==
"settings generalrecpriorities")
1240 "generalrecprioritiessettings",
1252 else if (sel ==
"settings channelrecpriorities")
1256 else if (sel ==
"settings custompriority")
1260 else if (sel ==
"system_events")
1271 else if (sel ==
"video_settings_general")
1274 GetBoolSetting(
"VideoAggressivePC",
false));
1276 else if (sel ==
"video_settings_player")
1287 else if (sel ==
"video_settings_metadata")
1298 else if (sel ==
"video_settings_associations")
1307 else if (sel ==
"manager")
1311 else if (sel ==
"browser")
1315 else if (sel ==
"listing")
1319 else if (sel ==
"gallery")
1323 else if (sel ==
"disc_play")
1327 else if (sel ==
"tv_status")
1331 else if (sel ==
"exiting_app_prompt")
1335 else if (sel ==
"exiting_app")
1339 else if (sel ==
"standby_mode")
1343 else if (sel ==
"exiting_menu")
1349 LOG(VB_GENERAL, LOG_ERR,
"Unknown menu action: " + selection);
1352 if (sel.startsWith(
"settings ") || sel ==
"video_settings_general")
1368 prompter->HandleExit();
1378 QByteArray tmp =
themedir.toLocal8Bit();
1384 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Found mainmenu.xml for theme '%1'")
1391 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find mainmenu.xml for theme '%1'")
1431 const QString &title,
const QString &subtitle,
1432 const QString &director,
int season,
int episode,
1433 const QString &inetref, std::chrono::minutes lenMins,
1434 const QString &year,
1435 const QString &
id,
const bool useBookmark)
1439 QFile checkFile(mrl);
1440 if ((!checkFile.exists() && !mrl.startsWith(
"dvd:")
1441 && !mrl.startsWith(
"bd:")
1442 && !mrl.startsWith(
"myth:")
1443 && !mrl.startsWith(
"http://")
1444 && !mrl.startsWith(
"https://")))
1446 QString errorText = QCoreApplication::translate(
"(MythFrontendMain)",
1447 "Failed to open \n '%1' in %2 \n"
1448 "Check if the video exists")
1449 .arg(mrl.section(
'/', -1),
1450 mrl.section(
'/', 0, -2));
1457 mrl, plot, title, QString(), subtitle, QString(),
1458 director, season, episode, inetref, lenMins,
1459 (year.toUInt()) ? year.toUInt() : 1900,
id);
1461 pginfo->SetProgramInfoType(pginfo->DiscoverProgramInfoType());
1463 bool bookmarkPresent =
false;
1464 bool lastPlayPresent =
false;
1466 if (pginfo->IsVideoDVD())
1468 auto *dvd =
new MythDVDInfo(pginfo->GetPlaybackURL());
1473 if (dvd->GetNameAndSerialNum(name, serialid))
1475 QStringList fields = pginfo->QueryDVDBookmark(serialid);
1476 bookmarkPresent = (fields.count() > 0);
1484 dvd->GetLastError());
1491 else if (pginfo->IsVideoBD())
1500 QStringList fields = pginfo->QueryBDBookmark(serialid);
1501 bookmarkPresent = (fields.count() > 0);
1514 else if (useBookmark && pginfo->IsVideo())
1516 pginfo->SetIgnoreLastPlayPos(
false);
1517 pginfo->SetIgnoreBookmark(
false);
1518 bookmarkPresent = pginfo->QueryBookmark() > 0;
1519 lastPlayPresent = pginfo->QueryLastPlayPos() > 0;
1522 if (useBookmark && (bookmarkPresent || lastPlayPresent))
1525 auto *bookmarkdialog =
new BookmarkDialog(pginfo, mainStack,
1528 if (!bookmarkdialog->Create())
1530 delete bookmarkdialog;
1550 auto *lmenu = qobject_cast<MythThemedMenuState *>
1553 lmenu->m_buttonList->SetItemCurrent(0);
1565 LOG(VB_GENERAL, LOG_WARNING, QString(
"Overriding broken theme '%1' with '%2'")
1566 .arg(badtheme, themename));
1585#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
1586 auto activity = QtAndroid::androidActivity();
1588 QJniObject activity = QNativeInterface::QAndroidApplication::context();
1590 auto packageManager = activity.callObjectMethod
1591 (
"getPackageManager",
1592 "()Landroid/content/pm/PackageManager;" );
1594 auto activityIntent = packageManager.callObjectMethod
1595 (
"getLaunchIntentForPackage",
1596 "(Ljava/lang/String;)Landroid/content/Intent;",
1597 activity.callObjectMethod(
"getPackageName",
1598 "()Ljava/lang/String;").object() );
1600 auto pendingIntent = QAndroidJniObject::callStaticObjectMethod
1601 (
"android/app/PendingIntent",
1603 "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;",
1606 activityIntent.object(),
1607 QAndroidJniObject::getStaticField<jint>(
"android/content/Intent",
1608 "FLAG_ACTIVITY_CLEAR_TOP") );
1610 auto alarmManager = activity.callObjectMethod
1611 (
"getSystemService",
1612 "(Ljava/lang/String;)Ljava/lang/Object;",
1613 QAndroidJniObject::getStaticObjectField(
"android/content/Context",
1615 "Ljava/lang/String;").
object() );
1617 alarmManager.callMethod<
void>
1619 "(IJLandroid/app/PendingIntent;)V",
1620 QAndroidJniObject::getStaticField<jint>(
"android/app/AlarmManager",
"RTC"),
1621 jlong(QDateTime::currentMSecsSinceEpoch() + 100),
1622 pendingIntent.object() );
1638 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'").arg(themename));
1690 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Reload Theme"),
1692 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Main Menu"),
1694 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Program Guide"),
1696 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Program Finder"),
1700 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Manage Recordings / "
1701 "Fix Conflicts"),
"",
"",
startManaged,
"VIEWSCHEDULED");
1702 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Manage Recording Rules"),
1704 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Channel Recording "
1706 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"TV Recording Playback"),
1708 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Live TV"),
1710 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Status Screen"),
1712 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Previously Recorded"),
1715 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Standby Mode"),
1730 REG_JUMP(
"Play Disc", QT_TRANSLATE_NOOP(
"MythControls",
1731 "Play an Optical Disc"),
"",
playDisc);
1738 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Toggle Show Widget Borders"),
1740 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Toggle Show Widget Names"),
1742 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Reset All Keys"),
1743 QT_TRANSLATE_NOOP(
"MythControls",
"Reset all keys to defaults"),
1756 REG_KEY(
"Video",
"PLAYALT", QT_TRANSLATE_NOOP(
"MythControls",
1757 "Play selected item in alternate player"),
"ALT+P");
1758 REG_KEY(
"Video",
"FILTER", QT_TRANSLATE_NOOP(
"MythControls",
1759 "Open video filter dialog"),
"F");
1760 REG_KEY(
"Video",
"INCPARENT", QT_TRANSLATE_NOOP(
"MythControls",
1761 "Increase Parental Level"),
"],},F11");
1762 REG_KEY(
"Video",
"DECPARENT", QT_TRANSLATE_NOOP(
"MythControls",
1763 "Decrease Parental Level"),
"[,{,F10");
1764 REG_KEY(
"Video",
"INCSEARCH", QT_TRANSLATE_NOOP(
"MythControls",
1765 "Show Incremental Search Dialog"),
"Ctrl+S,Search");
1766 REG_KEY(
"Video",
"DOWNLOADDATA", QT_TRANSLATE_NOOP(
"MythControls",
1767 "Download metadata for current item"),
"W");
1768 REG_KEY(
"Video",
"ITEMDETAIL", QT_TRANSLATE_NOOP(
"MythControls",
1769 "Display Item Detail Popup"),
"");
1772 REG_KEY(
"Images",
"PLAY", QT_TRANSLATE_NOOP(
"MythControls",
1773 "Start/Stop Slideshow"),
"P,Media Play");
1774 REG_KEY(
"Images",
"RECURSIVESHOW", QT_TRANSLATE_NOOP(
"MythControls",
1775 "Start Recursive Slideshow"),
"R");
1776 REG_KEY(
"Images",
"ROTRIGHT", QT_TRANSLATE_NOOP(
"MythControls",
1777 "Rotate image right 90 degrees"),
"],3");
1778 REG_KEY(
"Images",
"ROTLEFT", QT_TRANSLATE_NOOP(
"MythControls",
1779 "Rotate image left 90 degrees"),
"[,1");
1780 REG_KEY(
"Images",
"FLIPHORIZONTAL", QT_TRANSLATE_NOOP(
"MythControls",
1781 "Flip image horizontally"),
"");
1782 REG_KEY(
"Images",
"FLIPVERTICAL", QT_TRANSLATE_NOOP(
"MythControls",
1783 "Flip image vertically"),
"");
1784 REG_KEY(
"Images",
"ZOOMOUT", QT_TRANSLATE_NOOP(
"MythControls",
1785 "Zoom image out"),
"7,<,Ctrl+B,Media Rewind");
1786 REG_KEY(
"Images",
"ZOOMIN", QT_TRANSLATE_NOOP(
"MythControls",
1787 "Zoom image in"),
"9,>,Ctrl+F,Media Fast Forward");
1788 REG_KEY(
"Images",
"FULLSIZE", QT_TRANSLATE_NOOP(
"MythControls",
1789 "Full-size (un-zoom) image"),
"0");
1790 REG_KEY(
"Images",
"MARK", QT_TRANSLATE_NOOP(
"MythControls",
1791 "Mark image"),
"T");
1792 REG_KEY(
"Images",
"SCROLLUP", QT_TRANSLATE_NOOP(
"MythControls",
1793 "Scroll image up"),
"2");
1794 REG_KEY(
"Images",
"SCROLLLEFT", QT_TRANSLATE_NOOP(
"MythControls",
1795 "Scroll image left"),
"4");
1796 REG_KEY(
"Images",
"SCROLLRIGHT", QT_TRANSLATE_NOOP(
"MythControls",
1797 "Scroll image right"),
"6");
1798 REG_KEY(
"Images",
"SCROLLDOWN", QT_TRANSLATE_NOOP(
"MythControls",
1799 "Scroll image down"),
"8");
1800 REG_KEY(
"Images",
"RECENTER", QT_TRANSLATE_NOOP(
"MythControls",
1801 "Recenter image"),
"5");
1802 REG_KEY(
"Images",
"COVER", QT_TRANSLATE_NOOP(
"MythControls",
1803 "Set or clear cover image"),
"C");
1833 query.
prepare(
"DELETE FROM keybindings "
1834 "WHERE hostname = :HOSTNAME;");
1838 query.
prepare(
"DELETE FROM jumppoints "
1839 "WHERE hostname = :HOSTNAME;");
1883 query.
prepare(
"DELETE FROM inuseprograms "
1884 "WHERE hostname = :HOSTNAME and recusage = 'player' ;");
1892 bool autoStart =
false;
1898 QDateTime startupTime = QDateTime();
1907 if (startupTime.isValid())
1910 startupSecs = std::max(startupSecs, 15 * 60s);
1917 LOG(VB_GENERAL, LOG_INFO,
1918 "Close to auto-start time, AUTO-Startup assumed");
1924 LOG(VB_GENERAL, LOG_INFO,
1925 "Close to MythFillDB suggested run time, AUTO-Startup to fetch guide data?");
1931 LOG(VB_GENERAL, LOG_DEBUG,
1932 "NOT close to auto-start time, USER-initiated startup assumed");
1942 if (!wakeupCmd.isEmpty())
1945 bool bConflicts =
false;
1946 QDateTime nextRecordingStart;
1953 for (
auto *prog : progList)
1957 (prog->GetHostname() ==
hostname) &&
1958 (nextRecordingStart.isNull() ||
1959 nextRecordingStart > prog->GetRecordingStartTime()))
1961 nextRecordingStart = prog->GetRecordingStartTime();
1965 if (!nextRecordingStart.isNull() &&
1968 LOG(VB_GENERAL, LOG_INFO,
1969 "Close to start time, AUTO-Startup assumed");
1977 LOG(VB_GENERAL, LOG_DEBUG,
1978 "NOT close to auto-start time, USER-initiated startup assumed");
2004Q_DECL_EXPORT
int main(
int argc,
char **argv)
2006 bool bPromptForBackend =
false;
2007 bool bBypassAutoDiscovery =
false;
2028#if CONFIG_QTWEBENGINE
2029#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
2030 QtWebEngineQuick::initialize();
2032 QtWebEngine::initialize();
2037 QApplication::setSetuidAllowed(
true);
2038 QApplication a(argc, argv);
2042 QString path = QCoreApplication::applicationDirPath();
2043 qputenv(
"PYTHONPATH",
2044 QString(
"%1/../Resources/lib/%2:%1/../Resources/lib/%2/site-packages:%1/../Resources/lib/%2/lib-dynload:%3")
2046 .arg(QFileInfo(PYTHON_EXE).fileName())
2047 .arg(QProcessEnvironment::systemEnvironment().value(
"PYTHONPATH"))
2048 .toUtf8().constData());
2052 auto config = QSslConfiguration::defaultConfiguration();
2053 config.setCaCertificates(QSslConfiguration::systemCaCertificates());
2054 QSslConfiguration::setDefaultConfiguration(config);
2061 bool ResetSettings =
false;
2064 bPromptForBackend =
true;
2066 bBypassAutoDiscovery =
true;
2068 if (signal(
SIGPIPE, SIG_IGN) == SIG_ERR)
2069 std::cerr <<
"Unable to ignore SIGPIPE\n";
2079 if (!context.Init(
true, bPromptForBackend, bBypassAutoDiscovery))
2081 LOG(VB_GENERAL, LOG_ERR,
"Failed to init MythContext, exiting.");
2099 ResetSettings =
true;
2114 QDir dir(fileprefix);
2116 dir.mkdir(fileprefix);
2129 LOG(VB_GENERAL, LOG_NOTICE,
"Appearance settings and language have "
2130 "been reset to defaults. You will need to "
2131 "restart the frontend.");
2132 context.saveSettingsCache();
2136#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
2138 if (maxImageSize >=0)
2139 QImageReader::setAllocationLimit(maxImageSize);
2141 LOG(VB_GENERAL, LOG_DEBUG,
2142 QString(
"Built against zlib %1, linked against %2.")
2143 .arg(ZLIB_VERSION, zlibVersion()));
2144 QList<QByteArray>
formats = QImageReader::supportedImageFormats();
2145 QString format_str =
formats.takeFirst();
2146 for (
const auto& format : std::as_const(
formats))
2147 format_str +=
", " + format;
2148 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Supported image formats: %1").arg(format_str));
2150 QCoreApplication::setSetuidAllowed(
true);
2154 LOG(VB_GENERAL, LOG_ERR,
"Failed to revokeRoot(), exiting.");
2164 fe_sd_notify(
"STATUS=Registering frontend with bonjour");
2169 QByteArray name(
"Mythfrontend on ");
2171 bonjour->Register(port,
"_mythfrontend._tcp",
2190 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'")
2199 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'")
2213 mainWindow->Init(
false);
2214 mainWindow->setWindowTitle(QCoreApplication::translate(
"(MythFrontendMain)",
2216 "Main window title"));
2241 LOG(VB_GENERAL, LOG_ERR,
2242 "Couldn't upgrade database to new schema, exiting.");
2250 mainWindow->ReloadKeys();
2273 mainWindow->installEventFilter(mon);
2282 if (!networkControl->
listen(port))
2284 LOG(VB_GENERAL, LOG_ERR,
2285 QString(
"NetworkControl failed to bind to port %1.")
2301 std::unique_ptr<ThemeUpdateChecker> themeUpdateChecker;
2303 themeUpdateChecker = std::make_unique<ThemeUpdateChecker>();
2316 #ifdef CONFIG_BINDINGS_PYTHON
2320 housekeeping->Start();
2337 LOG(VB_GENERAL, LOG_ERR,
2338 QString(
"Invalid plugin name supplied on command line: '%1'")
2340 LOG(VB_GENERAL, LOG_ERR,
2341 QString(
"Available plugins: %1")
2342 .arg(plugins.join(
", ")));
2356 LOG(VB_GENERAL, LOG_ERR,
2357 QString(
"Invalid jump point supplied on the command line: %1")
2359 LOG(VB_GENERAL, LOG_ERR,
2360 QString(
"Available jump points: %2")
2387 auto root = [](
auto && PH1) {
return MythHTTPRoot::RedirectRoot(std::forward<
decltype(PH1)>(PH1),
"apps/frontend/index.html"); };
2389 ret = QCoreApplication::exec();
2394 context.saveSettingsCache();
2399 delete housekeeping;
2406 delete networkControl;
2412 LOG(VB_GENERAL, LOG_INFO,
"Reloading theme");
2421 LOG(VB_GENERAL, LOG_INFO,
"Restarting LIRC handler");
2429#include "mythfrontend.moc"
static const std::array< const std::string, 8 > formats
std::vector< ChannelInfo > ChannelInfoList
static void Cleanup(void)
Screen for managing channel priorities in recording scheduling decisions.
static ChannelInfoList LoadChannels(uint startIndex, uint count, uint &totalAvailable, bool ignoreHidden=true, OrderBy orderBy=kChanOrderByChanNum, GroupBy groupBy=kChanGroupByChanid, uint sourceID=0, uint channelGroupID=0, bool liveTVOnly=false, const QString &callsign="", const QString &channum="", bool ignoreUntunable=true)
Load channels from database into a list of ChannelInfo objects.
A screen to create a fully custom recording.
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
static void RunProgramGuide(uint startChanId, const QString &startChanNum, const QDateTime &startTime, TV *player=nullptr, bool embedVideo=false, bool allowFinder=true, int changrpid=-1)
Manages registered HouseKeeperTasks and queues tasks for operation.
static QStringList SupportedImages()
Return recognised pictures.
static QStringList SupportedVideos()
Return recognised video extensions.
static void SetupLCD(void)
static bool prompt(bool force=false)
Ask the user for the language to use.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void Cleanup(void)
QString GetLastError(void) const
bool GetNameAndSerialNum(QString &Name, QString &SerialNum)
static ImageType inspectImage(const QString &path)
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
void ApplySettingsOverride(void)
Apply all overrides to the global context.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
static void PrintVersion(void)
Print application version information.
void PrintHelp(void) const
Print command line option help.
Startup context for MythTV.
Screen for managing and configuring keyboard input bindings.
void emitTVPlaybackStarted(void)
void emitTVPlaybackStopped(void)
void ClearSettingsCache(const QString &myKey=QString(""))
void ActivateSettingsCache(bool activate=true)
QString GetHostName(void)
static bool BackendIsRunning(void)
a backend process is running on this host
void SaveSetting(const QString &key, int newValue)
void SetExiting(bool exiting=true)
QString GetSetting(const QString &key, const QString &defaultval="")
void OverrideSettingForSession(const QString &key, const QString &value)
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
T GetDurSetting(const QString &key, T defaultval=T::zero())
void SendMessage(const QString &message)
bool IsMasterHost(void)
is this the same host as the master
void SetPluginManager(MythPluginManager *pmanager)
int GetNumSetting(const QString &key, int defaultval=0)
void SetAsFrontend(bool frontend)
bool GetBoolSetting(const QString &key, bool defaultval=false)
static void DBError(const QString &where, const MSqlQuery &query)
Basic menu dialog, message and a list of options.
static void ConfigureQtGUI(int SwapInterval, const MythCommandLineParser &CmdLine)
Shared static initialisation code for all MythTV GUI applications.
static void AddErrorPageHandler(const HTTPHandler &Handler)
static void Addservices(const HTTPServices &Services)
static HTTPResponse RewriteToSPA(const HTTPRequest2 &Request, const QString &File)
A convenience method to seemlessly redirect requests to a Single Page web app (SPA)
static HTTPResponse RedirectRoot(const HTTPRequest2 &Request, const QString &File)
A convenience method to seemlessly redirect requests for index.html to a context specific file.
void ClearKeyContext(const QString &Context)
void PauseIdleTimer(bool Pause)
Pause the idle timeout timer.
MythScreenStack * GetMainStack()
void RestartInputHandlers()
void JumpTo(const QString &Destination, bool Pop=true)
MythPainter * GetPainter()
MythScreenStack * GetStack(const QString &Stackname)
bool DestinationExists(const QString &Destination) const
QStringList EnumerateDestinations() const
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
void SetEffectsEnabled(bool Enable)
void Init(bool MayReInit=true)
void SetDebugMode(bool showBorders, bool showNames)
bool ShowBorders(void) const
bool ShowTypeNames(void) const
bool run_plugin(const QString &plugname)
QStringList EnumeratePlugins(void)
static void Cleanup(void)
void GetScreenList(QVector< MythScreenType * > &screens)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
virtual MythScreenType * GetTopScreen(void) const
Screen in which all other widgets are contained and rendered.
virtual void Load(void)
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
An editor for MythSystemEvent handler commands.
Handles incoming MythSystemEvent messages.
static void reload()
Reload all active translators based on the current language setting.
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
QString RemoveCurrentLocation()
void AddCurrentLocation(const QString &Location)
static void ParseGeometryOverride(const QString &Geometry)
Parse an X11 style command line geometry string.
QString FindThemeDir(const QString &ThemeName, bool Fallback=true)
Returns the full path to the theme denoted by themename.
static void InitStatics(bool Reinit=false)
void SigResultReady(bool passwordValid, ParentalLevel::Level newLevel)
static void * RunPlaybackBox(void *player, bool showTV)
static void CreatePreviewGeneratorQueue(PreviewGenerator::Mode mode, uint maxAttempts, std::chrono::seconds minBlockSeconds)
Create the singleton queue of preview generators.
static void TeardownPreviewGeneratorQueue()
Destroy the singleton queue of preview generators.
static void * RunProgramList(void *player, ProgListType pltype, const QString &extraArg)
Holds information on recordings and videos.
static void * RunScheduleEditor(ProgramInfo *proginfo, void *player=nullptr)
Callback.
bool listen(QList< QHostAddress > addrs, quint16 port, bool requireall=true, PoolServerType type=kTCPServer)
void RunProlog(const QString &settingsPage)
static void SetHandler(int signum, SigHandlerFunc handler)
bool Create(void) override
Reports on various status items.
static void SetFuncPtr(const char *Name, void *Pointer)
Import pointers to functions used to embed the TV window into other containers e.g.
static bool StartTV(ProgramInfo *TVRec, uint Flags, const ChannelInfoList &Selection=ChannelInfoList())
Start playback of media.
static int ConfiguredTunerCards()
If any cards are configured, return the number.
View and select installed themes.
static VideoListDeathDelayPtr & GetSavedVideoList()
QPointer< class VideoListDeathDelay > VideoListDeathDelayPtr
static constexpr std::chrono::milliseconds kDelayTimeMS
Screen for viewing and managing upcoming and conflicted recordings.
static void * RunViewScheduled(void *player, bool showTv)
This dialog is used when playing something from the "Watch Videos" page. Playing from the "Watch Reco...
QString m_btnClearBookmark
QString m_btnPlayBookmark
void customEvent(QEvent *event) override
BookmarkDialog(ProgramInfo *pginfo, MythScreenStack *parent, bool bookmarkPresent, bool lastPlayPresent)
static void Create(bool check)
void OnPasswordResultReady(bool passwordValid, ParentalLevel::Level newLevel)
ParentalLevelChangeChecker m_plcc
~RunSettingsCompletion() override=default
RunSettingsCompletion(bool check)
bool InitializeMythSchema(void)
command to get the the initial database layout from an empty database:
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
@ GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_NO_THEME
No Theme available.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
@ GENERIC_EXIT_DB_ERROR
Database error.
@ GENERIC_EXIT_NOT_OK
Exited with error.
Implements Gallery Thumbnail screen.
const QString JUMP_VIDEO_TREE
const QString JUMP_VIDEO_GALLERY
const QString JUMP_VIDEO_MANAGER
const QString JUMP_VIDEO_DEFAULT
const QString JUMP_VIDEO_BROWSER
const QString JUMP_GALLERY_DEFAULT
static constexpr const char * MYTH_APPNAME_MYTHFRONTEND
Main header for mythcontrols.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
QString GetAppBinDir(void)
static void startKeysSetup()
static void startPlaybackWithGroup(const QString &recGroup="")
static void WriteDefaults()
static bool RunMenu(const QString &themedir, const QString &themename)
static void startManaged(void)
static void startChannelRecPriorities(void)
static void startTVNormal(void)
static void startSearchTime(void)
static void startSearchStored(void)
static void startGuide(void)
static bool isLiveTVAvailable(void)
static void standbyScreen(void)
static void startManageRecordingRules(void)
static void startSearchNew(void)
static void resetAllKeys(void)
Reset this host's key bindings and jump points to default values.
static void startPlayback(void)
static void TVMenuCallback(void *, QString &selection)
static SettingsHelper * g_settingsHelper
static MythPluginManager * g_pmanager
static void jumpScreenVideoDefault()
static void setDebugShowNames(void)
static void startSearchCategory(void)
static MediaRenderer * g_pUPnp
static void InitJumpPoints(void)
static void ReloadKeys(void)
static int internal_play_media(const QString &mrl, const QString &plot, const QString &title, const QString &subtitle, const QString &director, int season, int episode, const QString &inetref, std::chrono::minutes lenMins, const QString &year, const QString &id, const bool useBookmark)
static void startPreviousOld(void)
static void SetFuncPtrs(void)
static void jumpScreenVideoBrowser()
static int reloadTheme(void)
static void startCustomEdit(void)
static void jumpScreenVideoGallery()
static void startSearchKeyword(void)
static void handleDVDMedia(MythMediaDevice *dvd, bool)
static void showStatus(void)
static void startSearchPeople(void)
static void startSearchPower(void)
static MythThemedMenu * g_menu
static void startFinder(void)
static void gotoMainMenu(void)
static void handleGalleryMedia(MythMediaDevice *dev, bool forcePlayback)
static void startPrevious(void)
static void startSearchTitle(void)
Q_DECL_EXPORT int main(int argc, char **argv)
static void clearAllKeys(void)
Deletes all key bindings and jump points for this host.
static void startSearchMovie(void)
static bool WasAutomaticStart(void)
static void ReloadJumpPoints(void)
static void startSearchChannel(void)
static void jumpScreenVideoManager()
static void startAppearWiz(void)
static int internal_media_init()
static void fe_sd_notify(const char *)
static void reloadTheme_void(void)
static bool resetTheme(QString themedir, const QString &badtheme)
static int revokeRoot(void)
static void startCustomPriority(void)
static void InitKeys(void)
static void CleanupMyOldInUsePrograms(void)
static void jumpScreenVideoTree()
static void startManualSchedule(void)
static void handleExit(bool prompt)
static void RunVideoScreen(VideoDialog::DialogType type, bool fromJump=false)
static void setDebugShowBorders(void)
static const QString sLocation
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
static void REG_JUMPLOC(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), const QString &LocalAction)
static void REG_JUMPEX(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void), bool ExitToMain)
static void REG_MEDIAPLAYER(const QString &Name, const QString &Desc, MediaPlayCallback Func)
static void REG_JUMP(const QString &Destination, const QString &Description, const QString &Key, void(*Callback)(void))
static void REG_KEY(const QString &Context, const QString &Action, const QString &Description, const QString &Key)
void setHttpProxy(void)
Get network proxy settings from OS, and use for [Q]Http[Comms].
void ShowNotificationError(const QString &msg, const QString &from, const QString &detail, const VNMask visibility, const MythNotification::Priority priority)
convenience utility to display error message as notification
@ kMSPropagateLogs
add arguments for MythTV log propagation
@ kMSDisableUDPListener
disable MythMessage UDP listener for the duration of application.
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
MythUIHelper * GetMythUI()
static constexpr const char * FALLBACK_UI_THEME
static constexpr const char * DEFAULT_UI_THEME
std::chrono::seconds secsInPast(const QDateTime &past)
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
MythCommFlagCommandLineParser cmdline
void RunProgramFinder(TV *player, bool embedVideo, bool allowEPG)
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, const QString &altTable="", int recordid=-1)
@ kStartTVIgnoreLastPlayPos
int RemoteGetFreeRecorderCount(void)
int RemoteGetRecordingMask(void)