17 #include <QApplication>
23 #include "mythconfig.h"
51 #include "exitprompt.h"
65 #include "commandlineparser.h"
99 #ifdef USING_LIBDNS_SD
100 #include <QScopedPointer>
119 class RunSettingsCompletion :
public QObject
124 static void Create(
bool check)
126 new RunSettingsCompletion(check);
130 RunSettingsCompletion(
bool check)
136 SLOT(OnPasswordResultReady(
bool,
146 ~RunSettingsCompletion() {}
149 void OnPasswordResultReady(
bool passwordValid,
161 LOG(VB_GENERAL, LOG_WARNING,
162 QObject::tr(
"Aggressive Parental Controls Warning: "
163 "invalid password. An attempt to enter a "
164 "MythVideo settings screen was prevented."));
185 QString msg = QObject::tr(
"DVD/Video contains a bookmark");
186 QString btn0msg = QObject::tr(
"Play from bookmark");
187 QString btn1msg = QObject::tr(
"Play from beginning");
196 GetScreenStack()->AddScreen(popup);
204 void customEvent(QEvent *event)
211 if (dce->
GetId() ==
"bookmarkdialog")
218 else if (buttonnum != 0)
250 LOG(VB_GENERAL, LOG_INFO,
"Deleting UPnP client...");
276 typedef void (*CleanupFunc)();
279 CleanupGuard(CleanupFunc cleanFunction) :
280 m_cleanFunction(cleanFunction) {}
288 CleanupFunc m_cleanFunction;
335 if (mythcontrols->
Create())
345 channum = (channum.isEmpty()) ?
"3" : channum;
474 if (progRecPrior->
Create())
486 if (chanRecPrior->
Create())
509 mainStack,
"playbackbox");
513 if (!recGroup.isEmpty())
565 QString msg = QObject::tr(
"All tuners are currently busy.");
567 msg = QObject::tr(
"There are no configured tuners.");
612 QString message = QObject::tr(
"Loading videos ...");
618 popupStack,
"mythvideobusydialog");
632 video_list = saved->GetSaved();
644 new VideoDialog(mainStack,
"mythvideo", video_list, type, browse);
669 QString command_string =
671 QString bluray_mountpoint =
673 QDir bdtest(bluray_mountpoint +
"/BDMV");
682 QString filename = QString(
"bd:/%1").arg(bluray_mountpoint);
685 0, 0,
"", 0,
"",
"",
true);
693 if (dvd_device.isEmpty())
698 if ((command_string.indexOf(
"internal", 0, Qt::CaseInsensitive) > -1) ||
699 (command_string.length() < 1))
703 QString filename =
"dvd://dev/r";
705 QString filename =
"dvd:";
707 QString filename =
"dvd:/";
709 filename += dvd_device;
711 command_string =
"Internal";
713 "",
"", 0, 0,
"", 0,
"",
"",
true);
720 if (command_string.contains(
"%d"))
726 command_string.replace(QRegExp(
"%d"), dvd_device);
768 LOG(VB_GENERAL, LOG_ERR,
769 "mythdvd main.o: handleMedia() does not know what to do");
776 QString sel = selection.toLower();
778 if (sel.startsWith(
"settings "))
785 if (sel ==
"tv_watch_live")
787 else if (sel ==
"tv_watch_live_epg")
789 else if (sel.startsWith(
"tv_watch_recording"))
792 if ((selection.length() > 19) && (selection.mid(18, 1) ==
" "))
797 else if (sel ==
"tv_schedule")
799 else if (sel ==
"tv_manualschedule")
801 else if (sel ==
"tv_custom_record")
803 else if (sel ==
"tv_fix_conflicts")
805 else if (sel ==
"tv_manage_recording_rules")
807 else if (sel ==
"tv_progfind")
809 else if (sel ==
"tv_search_title")
811 else if (sel ==
"tv_search_keyword")
813 else if (sel ==
"tv_search_people")
815 else if (sel ==
"tv_search_power")
817 else if (sel ==
"tv_search_stored")
819 else if (sel ==
"tv_search_channel")
821 else if (sel ==
"tv_search_category")
823 else if (sel ==
"tv_search_movie")
825 else if (sel ==
"tv_search_new")
827 else if (sel ==
"tv_search_time")
829 else if (sel ==
"tv_previous")
831 else if (sel ==
"settings appearance")
839 qApp->processEvents();
843 else if (sel ==
"settings themechooser")
853 else if (sel ==
"settings setupwizard")
863 else if (sel ==
"settings grabbers")
873 else if (sel ==
"screensetupwizard")
877 else if (sel ==
"setup_keys")
881 else if (sel ==
"settings playgroup")
886 else if (sel ==
"settings general")
891 else if (sel ==
"settings audiogeneral")
894 audiosettings.
exec();
896 else if (sel ==
"settings maingeneral")
900 QStringList strlist( QString(
"REFRESH_BACKEND") );
903 else if (sel ==
"settings playback")
908 else if (sel ==
"settings osd")
913 else if (sel ==
"settings epg")
918 else if (sel ==
"settings channelgroups")
923 else if (sel ==
"settings generalrecpriorities")
928 else if (sel ==
"settings channelrecpriorities")
932 else if (sel ==
"settings custompriority")
936 else if (sel ==
"system_events")
941 mainStack,
"System Event Editor");
948 else if (sel ==
"video_settings_general")
951 GetNumSetting(
"VideoAggressivePC", 0));
953 else if (sel ==
"video_settings_player")
962 else if (sel ==
"video_settings_metadata")
971 else if (sel ==
"video_settings_associations")
980 else if (sel ==
"manager")
982 else if (sel ==
"browser")
984 else if (sel ==
"listing")
986 else if (sel ==
"gallery")
988 else if (sel ==
"disc_play")
992 else if (sel ==
"tv_status")
994 else if (sel ==
"exiting_app_prompt")
996 else if (sel ==
"exiting_app")
998 else if (sel ==
"standby_mode")
1001 LOG(VB_GENERAL, LOG_ERR,
"Unknown menu action: " + selection);
1003 if (sel.startsWith(
"settings ") || sel ==
"video_settings_general")
1010 if (sel ==
"settings general" ||
1011 sel ==
"settings generalrecpriorities")
1032 QByteArray
tmp = themedir.toLocal8Bit();
1038 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Found mainmenu.xml for theme '%1'")
1045 LOG(VB_GENERAL, LOG_ERR,
1046 QString(
"Couldn't find mainmenu.xml for theme '%1'") .arg(themename));
1084 const QString &title,
const QString &subtitle,
1085 const QString &director,
int season,
int episode,
1086 const QString &inetref,
int lenMins,
const QString &year,
1087 const QString &
id,
const bool useBookmark)
1091 QFile checkFile(mrl);
1092 if ((!checkFile.exists() && !mrl.startsWith(
"dvd:")
1093 && !mrl.startsWith(
"bd:")
1094 && !mrl.startsWith(
"myth:")
1095 && !mrl.startsWith(
"http://")))
1097 QString errorText = QObject::tr(
"Failed to open \n '%1' in %2 \n"
1098 "Check if the video exists")
1099 .arg(mrl.section(
'/', -1))
1100 .arg(mrl.section(
'/', 0, -2));
1106 mrl, plot, title, subtitle, director, season, episode,
1107 inetref, lenMins, (year.toUInt()) ? year.toUInt() : 1900,
1124 if (!fields.empty())
1126 QStringList::Iterator it = fields.begin();
1127 pos = (int64_t)((*++it).toLongLong() & 0xffffffffLL);
1143 if (useBookmark && pos > 0)
1146 BookmarkDialog *bookmarkdialog =
new BookmarkDialog(pginfo, mainStack);
1147 if (!bookmarkdialog->Create())
1149 delete bookmarkdialog;
1179 QString themename = DEFAULT_UI_THEME;
1181 if (badtheme == DEFAULT_UI_THEME)
1182 themename = FALLBACK_UI_THEME;
1184 LOG(VB_GENERAL, LOG_WARNING,
1185 QString(
"Overriding broken theme '%1' with '%2'")
1186 .arg(badtheme).arg(themename));
1202 return RunMenu(themedir, themename);
1209 if (themedir.isEmpty())
1211 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'")
1213 return GENERIC_EXIT_NO_THEME;
1238 return GENERIC_EXIT_NO_THEME;
1277 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Reload Theme"),
1279 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Main Menu"),
1281 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Program Guide"),
1283 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Program Finder"),
1287 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"Manage Recordings / "
1288 "Fix Conflicts"),
"",
"",
startManaged,
"VIEWSCHEDULED");
1289 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Manage Recording Rules"),
1291 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Channel Recording "
1293 REG_JUMPLOC(QT_TRANSLATE_NOOP(
"MythControls",
"TV Recording Playback"),
1295 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Live TV"),
1297 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Live TV In Guide"),
1299 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Status Screen"),
1301 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Previously Recorded"),
1304 REG_JUMP(QT_TRANSLATE_NOOP(
"MythControls",
"Standby Mode"),
1319 REG_JUMP(
"Play Disc", QT_TRANSLATE_NOOP(
"MythControls",
1320 "Play an Optical Disc"),
"",
playDisc);
1322 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Toggle Show Widget Borders"),
1324 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Toggle Show Widget Names"),
1326 REG_JUMPEX(QT_TRANSLATE_NOOP(
"MythControls",
"Reset All Keys"),
1327 QT_TRANSLATE_NOOP(
"MythControls",
"Reset all keys to defaults"),
1340 REG_KEY(
"Video",
"PLAYALT", QT_TRANSLATE_NOOP(
"MythControls",
1341 "Play selected item in alternate player"),
"ALT+P");
1342 REG_KEY(
"Video",
"FILTER", QT_TRANSLATE_NOOP(
"MythControls",
1343 "Open video filter dialog"),
"F");
1344 REG_KEY(
"Video",
"BROWSE", QT_TRANSLATE_NOOP(
"MythControls",
1345 "Change browsable in video manager"),
"B");
1346 REG_KEY(
"Video",
"INCPARENT", QT_TRANSLATE_NOOP(
"MythControls",
1347 "Increase Parental Level"),
"],},F11");
1348 REG_KEY(
"Video",
"DECPARENT", QT_TRANSLATE_NOOP(
"MythControls",
1349 "Decrease Parental Level"),
"[,{,F10");
1350 REG_KEY(
"Video",
"INCSEARCH", QT_TRANSLATE_NOOP(
"MythControls",
1351 "Show Incremental Search Dialog"),
"Ctrl+S");
1352 REG_KEY(
"Video",
"DOWNLOADDATA", QT_TRANSLATE_NOOP(
"MythControls",
1353 "Download metadata for current item"),
"W");
1354 REG_KEY(
"Video",
"ITEMDETAIL", QT_TRANSLATE_NOOP(
"MythControls",
1355 "Display Item Detail Popup"),
"");
1356 REG_KEY(
"Video",
"HOME", QT_TRANSLATE_NOOP(
"MythControls",
1357 "Go to the first video"),
"Home");
1358 REG_KEY(
"Video",
"END", QT_TRANSLATE_NOOP(
"MythControls",
1359 "Go to the last video"),
"End");
1386 query.
prepare(
"DELETE FROM keybindings "
1387 "WHERE hostname = :HOSTNAME;");
1391 query.
prepare(
"DELETE FROM jumppoints "
1392 "WHERE hostname = :HOSTNAME;");
1414 REG_MEDIAPLAYER(
"Internal", QT_TRANSLATE_NOOP(
"MythControls",
1416 REG_MEDIA_HANDLER(QT_TRANSLATE_NOOP(
"MythControls",
1426 query.
prepare(
"DELETE FROM inuseprograms "
1427 "WHERE hostname = :HOSTNAME and recusage = 'player' ;");
1435 bool bPromptForBackend =
false;
1436 bool bBypassAutoDiscovery =
false;
1439 if (!cmdline.
Parse(argc, argv))
1442 return GENERIC_EXIT_INVALID_CMDLINE;
1445 if (cmdline.
toBool(
"showhelp"))
1448 return GENERIC_EXIT_OK;
1451 if (cmdline.
toBool(
"showversion"))
1454 return GENERIC_EXIT_OK;
1457 CleanupGuard callCleanup(
cleanup);
1462 QApplication::setDesktopSettingsAware(
false);
1464 new QApplication(argc, argv);
1465 QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHFRONTEND);
1468 QList<int> signallist;
1469 signallist << SIGINT << SIGTERM << SIGSEGV << SIGABRT << SIGBUS << SIGFPE
1472 signallist << SIGRTMIN;
1477 signal(SIGHUP, SIG_IGN);
1484 bool ResetSettings =
false;
1486 if (cmdline.
toBool(
"prompt"))
1487 bPromptForBackend =
true;
1488 if (cmdline.
toBool(
"noautodiscovery"))
1489 bBypassAutoDiscovery =
true;
1491 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
1492 cerr <<
"Unable to ignore SIGPIPE\n";
1494 if (!cmdline.
toString(
"display").isEmpty())
1499 if (!cmdline.
toString(
"geometry").isEmpty())
1506 if (!
gContext->
Init(
true, bPromptForBackend, bBypassAutoDiscovery))
1508 LOG(VB_GENERAL, LOG_ERR,
"Failed to init MythContext, exiting.");
1509 return GENERIC_EXIT_NO_MYTHCONTEXT;
1517 return GENERIC_EXIT_DB_ERROR;
1520 if (cmdline.
toBool(
"reset"))
1521 ResetSettings =
true;
1523 if (!cmdline.
toBool(
"noupnp"))
1535 QDir dir(fileprefix);
1537 dir.mkdir(fileprefix);
1548 return GENERIC_EXIT_OK;
1553 #ifdef USING_LIBDNS_SD
1561 QByteArray
name(
"Mythfrontend on ");
1563 bonjour->Register(port,
"_mythfrontend._tcp",
1568 #ifdef USING_AIRPLAY
1588 if (themedir.isEmpty())
1590 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'")
1592 return GENERIC_EXIT_NO_THEME;
1599 if (themedir.isEmpty())
1601 LOG(VB_GENERAL, LOG_ERR, QString(
"Couldn't find theme '%1'")
1603 return GENERIC_EXIT_NO_THEME;
1608 mainWindow->
Init(OPENGL_PAINTER);
1612 mainWindow->setWindowTitle(QObject::tr(
"MythTV Frontend"));
1620 return GENERIC_EXIT_NO_THEME;
1625 LOG(VB_GENERAL, LOG_ERR,
1626 "Couldn't upgrade database to new schema, exiting.");
1627 return GENERIC_EXIT_DB_OUTOFDATE;
1654 mainWindow->installEventFilter(mon);
1662 if (!networkControl->
listen(port))
1663 LOG(VB_GENERAL, LOG_ERR,
1664 QString(
"NetworkControl failed to bind to port %1.")
1669 #ifdef CONFIG_BINDINGS_PYTHON
1679 return GENERIC_EXIT_NO_THEME;
1693 if (cmdline.
toBool(
"runplugin"))
1697 if (plugins.contains(cmdline.
toString(
"runplugin")))
1699 else if (plugins.contains(
"myth" + cmdline.
toString(
"runplugin")))
1703 LOG(VB_GENERAL, LOG_ERR,
1704 QString(
"Invalid plugin name supplied on command line: '%1'")
1705 .arg(cmdline.
toString(
"runplugin")));
1706 LOG(VB_GENERAL, LOG_ERR,
1707 QString(
"Available plugins: %1")
1708 .arg(plugins.join(
", ")));
1709 return GENERIC_EXIT_INVALID_CMDLINE;
1712 else if (cmdline.
toBool(
"jumppoint"))
1720 LOG(VB_GENERAL, LOG_ERR,
1721 QString(
"Invalid jump point supplied on the command line: %1")
1722 .arg(cmdline.
toString(
"jumppoint")));
1723 LOG(VB_GENERAL, LOG_ERR,
1724 QString(
"Available jump points: %2")
1726 return GENERIC_EXIT_INVALID_CMDLINE;
1730 int ret = qApp->exec();
1734 if (themeUpdateChecker)
1735 delete themeUpdateChecker;
1737 delete sysEventHandler;
1744 delete networkControl;
1752 LOG(VB_GENERAL, LOG_INFO,
"Reloading theme");
1761 LOG(VB_GENERAL, LOG_INFO,
"Restarting LIRC handler");