13#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
14#include <QtSystemDetection>
16#include <QCoreApplication>
26#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
27#include <QtAndroidExtras>
29#include <QJniEnvironment>
31#define QAndroidJniEnvironment QJniEnvironment
32#define QAndroidJniObject QJniObject
53#include "libmythbase/mythversion.h"
74#define LOC QString("MythContext: ")
84 : m_cachePath(
std::move(cache_path))
86 m_cacheFilename = m_cachePath +
'/' + cache_filename;
87 if (m_cachePath.isEmpty() || cache_filename.isEmpty())
89 m_cacheFilename = m_cachePath = QString();
94 void loadOverrides()
const;
95 static void clearOverrides();
98 QString m_cacheFilename {
"cache/contextcache.xml"};
99 QString m_cachePath {
"cache"};
115 bool promptForBackend,
116 bool disableAutoDiscovery,
137 static int UPnPautoconf(std::chrono::milliseconds milliSeconds = 2s);
141 bool checkPort(QString &host,
int port, std::chrono::seconds timeLimit)
const;
145 bool event(QEvent* )
override;
187 QStringList tokens = cmd.simplified().split(
" ");
190 bool cardidok =
false;
191 int wantcardid = tokens[0].toInt(&cardidok, 10);
193 if (cardidok && wantcardid > 0)
195 strlist << QString(
"LOCK_TUNER %1").arg(wantcardid);
196 s = s.replace(0, tokens[0].length() + 1,
"");
200 strlist <<
"LOCK_TUNER";
204 int cardid = strlist[0].toInt();
208 s = s.arg(qPrintable(strlist[1]),
209 qPrintable(strlist[2]),
210 qPrintable(strlist[3]));
214 strlist = QStringList(QString(
"FREE_TUNER %1").arg(cardid));
225 label = QObject::tr(
"Could not find specified tuner (%1).")
230 label = QObject::tr(
"Specified tuner (%1) is already in use.")
236 label = QObject::tr(
"All tuners are currently in use. If you want "
237 "to watch TV, you can cancel one of the "
238 "in-progress recordings from the delete menu");
241 LOG(VB_GENERAL, LOG_ALERT, QString(
"exec_program_tv: ") + label);
256 QObject::tr(
"Failed to configure plugin"));
270 QObject::tr(
"%1 failed to run for some reason").arg(cmd));
280 : m_loop(new QEventLoop(this))
328 if (m_guiStartup && !m_guiStartup->m_Exit)
333 mainStack->
PopScreen(m_guiStartup,
false);
334 m_guiStartup =
nullptr;
362 return checker.
checkPort(host, port, timeLimit);
367 const bool promptForBackend,
368 const bool disableAutoDiscovery,
375 m_GUISettingsCache.loadOverrides();
379 m_needsBackend =
true;
387 if (!ignoreDB && !FindDatabase(promptForBackend, disableAutoDiscovery))
410 mainStack->
PopScreen(m_guiStartup,
false);
411 m_guiStartup=
nullptr;
446 if (DefaultUPnP(failure))
447 autoSelect = manualSelect =
false;
449 if (!failure.isEmpty())
450 LOG(VB_GENERAL, LOG_ALERT, failure);
452 failure = TestDBconnection(loaded);
453 if (failure.isEmpty())
455 if (m_guiStartup && m_guiStartup->m_Exit)
457 if (m_guiStartup && m_guiStartup->m_Search)
464 int count = UPnPautoconf();
467 failure = QObject::tr(
"No UPnP backends found",
"Backend Setup");
471 failure = TestDBconnection();
472 if (failure.isEmpty())
474 if (m_guiStartup && m_guiStartup->m_Exit)
479 manualSelect |= (count > 1 || count == -1);
481 if (m_guiStartup && m_guiStartup->m_Search)
485 manualSelect &= m_gui;
488 bool haveDbInfo {
false};
494 switch (ChooseBackend(failure))
499 manualSelect =
false;
503 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - failed");
515 || !PromptForDatabaseParams(failure))
517 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - failed");
521 failure = TestDBconnection();
522 haveDbInfo = failure.isEmpty();
523 if (!failure.isEmpty())
524 LOG(VB_GENERAL, LOG_ALERT, failure);
525 if (m_guiStartup && m_guiStartup->m_Exit)
527 if (m_guiStartup && m_guiStartup->m_Search)
529 if (m_guiStartup && m_guiStartup->m_Setup)
551 bool manualSelect = prompt && !noAutodetect;
554 bool loaded = LoadDatabaseSettings();
561 bool autoSelect = !manualSelect && !loaded && !noAutodetect;
563 if (!FindDatabaseChoose(loaded, manualSelect, autoSelect))
566 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - Success!");
575 GetMythDB()->SaveDatabaseParams(dbParams, !loaded || dbParamsFromFile != dbParams);
577 ResetDatabase(dbParams);
612 GetMythDB()->SetDatabaseParams(dbParams);
619 hostname ==
"my-unique-identifier-goes-here")
621 LOG(VB_GENERAL, LOG_INFO,
"Empty LocalHostName. This is typical.");
622 hostname = QHostInfo::localHostName();
627 LOG(VB_GENERAL, LOG_ALERT,
628 "MCP: Error, could not determine host name." +
ENO);
631#define ANDROID_EXCEPTION_CHECK \
632 if (env->ExceptionCheck()) \
634 env->ExceptionClear(); \
641 bool exception=
false;
644#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
647 QJniObject activity = QNativeInterface::QAndroidApplication::context();
651 (
"getApplicationContext",
"()Landroid/content/Context;");
654 (
"getContentResolver",
"()Landroid/content/ContentResolver;");
657 (
"android/provider/Settings$Secure",
"getString",
658 "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
659 contentR.object<jobject>(),
660 myID.object<jstring>());
663 LOG(VB_GENERAL, LOG_ALERT,
664 "Java exception looking for android id");
666 hostname = QString(
"android-%1").arg(androidId.toString());
672 LOG(VB_GENERAL, LOG_INFO, QString(
"Using a profile name of: '%1' (Usually the "
673 "same as this host's name.)")
683 if (m_loop && m_loop->isRunning())
696 bool accepted =
false;
703 if (!
error.isEmpty())
718 if (!m_loop->isRunning())
733 std::this_thread::sleep_for(1s);
735 std::cout << std::endl <<
error.toLocal8Bit().constData() << std::endl << std::endl;
736 response =
getResponse(
"Would you like to configure the database "
739 if (!response.startsWith(
'y', Qt::CaseInsensitive))
744 response =
getResponse(
"Should I test connectivity to this host "
745 "using the ping command?",
"yes");
746 params.
m_dbHostPing = response.startsWith(
'y', Qt::CaseInsensitive);
758 "(if empty, the local host name "
763 response =
getResponse(
"Would you like to use Wake-On-LAN to retry "
764 "database connections?",
766 params.
m_wolEnabled = response.startsWith(
'y', Qt::CaseInsensitive);
771 std::chrono::seconds(
intResponse(
"Seconds to wait for "
780 accepted =
GetMythDB()->SaveDatabaseParams(params,
false);
804 enum startupStates : std::uint8_t {
812 } startupState = st_start;
814 static const std::array<const QString, 7> kGuiStatuses
815 {
"start",
"dbAwake",
"dbStarted",
"dbConnects",
"beWOL",
"beAwake",
"success"};
818 auto msStartupScreenDelay = std::chrono::duration_cast<std::chrono::milliseconds>(secondsStartupScreenDelay);
824 if (dbParams.
m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
831 std::chrono::seconds wakeupTime = 3s;
837 startupState = st_start;
841 startupState = st_dbAwake;
843 attempts = std::max(attempts, 6);
849 std::chrono::seconds progressTotal = wakeupTime * attempts;
851 if (m_guiStartup && !m_guiStartup->m_Exit)
852 m_guiStartup->setTotal(progressTotal);
854 QString beWOLCmd = QString();
855 QString backendIP = QString();
857 QString masterserver;
859 for (
int attempt = 0;
860 attempt < attempts && startupState != st_success;
867 LOG(VB_GENERAL, LOG_INFO,
868 QString(
"Start up testing connections. DB %1, BE %2, attempt %3, status %4, Delay: %5")
869 .arg(host, backendIP, QString::number(attempt),
870 kGuiStatuses[startupState],
871 QString::number(msStartupScreenDelay.count())) );
873 std::chrono::seconds useTimeout = wakeupTime;
877 if (m_gui && !m_guiStartup)
879 if (msStartupScreenDelay==0ms || timer.hasExpired(msStartupScreenDelay.count()))
883 m_guiStartup->setTotal(progressTotal);
886 if (m_guiStartup && !m_guiStartup->m_Exit)
889 m_guiStartup->setStatusState(kGuiStatuses[startupState]);
890 m_guiStartup->setMessageState(
"empty");
893 switch (startupState)
900 if (!checkPort(host, port, useTimeout))
903 startupState = st_dbAwake;
906 if (!checkPort(host, port, useTimeout))
908 startupState = st_dbStarted;
916 GetMythDB()->SetDatabaseParams(dbParams);
919 ResetDatabase(dbParams);
922 for (std::chrono::seconds temp = 0s; temp < useTimeout * 2 ; temp++)
925 std::this_thread::sleep_for(500ms);
929 startupState = st_dbConnects;
935 if (!beWOLCmd.isEmpty())
938 (
"WOLbackendReconnectWaitTime", 0s);
940 (
"WOLbackendConnectRetry", 0);
941 useTimeout = wakeupTime;
942 if (m_gui && !m_guiStartup && attempt == 0)
944 progressTotal = wakeupTime * attempts;
945 if (m_guiStartup && !m_guiStartup->m_Exit)
946 m_guiStartup->setTotal(progressTotal);
947 startupState = st_beWOL;
952 startupState = st_success;
956 (
"MasterServerName");
958 (
"BackendServerAddr", masterserver);
962 if (!beWOLCmd.isEmpty())
966 if (!checkPort(backendIP, backendPort, useTimeout))
969 startupState = st_beAwake;
972 if (!checkPort(backendIP, backendPort, useTimeout))
974 startupState = st_success;
982 if (m_guiStartup->m_Exit
983 || m_guiStartup->m_Setup
984 || m_guiStartup->m_Search
985 || m_guiStartup->m_Retry)
990 if (startupState == st_success)
993 QString stateMsg = kGuiStatuses[startupState];
994 stateMsg.append(
"Fail");
995 LOG(VB_GENERAL, LOG_INFO,
996 QString(
"Start up failure. host %1, status %2")
997 .arg(host, stateMsg));
999 if (m_gui && !m_guiStartup)
1003 m_guiStartup->setTotal(progressTotal);
1007 && !m_guiStartup->m_Exit
1008 && !m_guiStartup->m_Setup
1009 && !m_guiStartup->m_Search
1010 && !m_guiStartup->m_Retry)
1012 m_guiStartup->updateProgress(
true);
1013 m_guiStartup->setStatusState(stateMsg);
1014 m_guiStartup->setMessageState(
"makeselection");
1018 while (m_guiStartup && m_guiStartup->m_Retry);
1020 if (startupState < st_dbAwake)
1022 LOG(VB_GENERAL, LOG_WARNING, QString(
"Pinging to %1 failed, database will be unavailable").arg(host));
1025 "Cannot find (ping) database host %1 on the network",
1027 return err.arg(host);
1030 if (startupState < st_dbConnects)
1033 return QObject::tr(
"Cannot login to database",
"Backend Setup");
1036 if (startupState < st_success)
1038 return QObject::tr(
"Cannot connect to backend",
"Backend Setup");
1043 ResetDatabase(dbParams);
1062 m_guiStartup =
new GUIStartup(mainStack, m_loop);
1063 if (!m_guiStartup->Create())
1065 delete m_guiStartup;
1066 m_guiStartup =
nullptr;
1070 mainStack->
AddScreen(m_guiStartup,
false);
1098 GetMythDB()->SetDatabaseParams(dbParams);
1106 if (dbParams.
m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
1109 GetMythDB()->SetDatabaseParams(dbParams);
1130 db->GetDBManager()->CloseDatabases();
1131 db->SetDatabaseParams(dbParams);
1132 db->ClearSettingsCache();
1144 if (!
error.isEmpty())
1146 LOG(VB_GENERAL, LOG_ERR, QString(
"Error: %1").arg(
error));
1150 LOG(VB_GENERAL, LOG_INFO,
"Putting up the UPnP backend chooser");
1155 GetMythDB()->SetDatabaseParams(dbParams);
1170 auto seconds = duration_cast<std::chrono::seconds>(milliSeconds);
1171 LOG(VB_GENERAL, LOG_INFO, QString(
"UPNP Search %1 secs")
1172 .arg(seconds.count()));
1180 while (totalTime.
elapsed() < milliSeconds)
1183 auto ttl = milliSeconds - totalTime.
elapsed();
1184 if ((searchTime.
elapsed() > 249ms) && (ttl > 1s))
1186 auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1187 LOG(VB_GENERAL, LOG_INFO, QString(
"UPNP Search %1 secs")
1188 .arg(ttlSeconds.count()));
1198 LOG(VB_GENERAL, LOG_INFO,
"No UPnP backends found");
1202 int count = backends->
Count();
1205 LOG(VB_GENERAL, LOG_INFO,
1206 QString(
"Found %1 UPnP backends").arg(count));
1210 LOG(VB_GENERAL, LOG_ERR,
1211 "No UPnP backends found, but SSDPCache::Instance()->Find() not NULL");
1227 int ret = (UPnPconnect(BE, QString())) ? 1 : -1;
1241 static const QString loc =
"DefaultUPnP() - ";
1254 LOG(VB_UPNP, LOG_INFO, loc +
"No default UPnP backend");
1258 LOG(VB_UPNP, LOG_INFO,
1260 QString(
" has default PIN '%1' and host USN: %2").arg(pin, usn));
1264 std::chrono::milliseconds timeout_ms {2s};
1265 auto timeout_s = duration_cast<std::chrono::seconds>(timeout_ms);
1266 LOG(VB_GENERAL, LOG_INFO, loc + QString(
"UPNP Search up to %1 secs")
1267 .arg(timeout_s.count()));
1279 while (totalTime.
elapsed() < timeout_ms)
1287 auto ttl = timeout_ms - totalTime.
elapsed();
1288 if ((searchTime.
elapsed() > 249ms) && (ttl > 1s))
1290 auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1291 LOG(VB_GENERAL, LOG_INFO, loc + QString(
"UPNP Search up to %1 secs")
1292 .arg(ttlSeconds.count()));
1300 if (!devicelocation)
1302 Error =
"Cannot find default UPnP backend";
1306 if (UPnPconnect(devicelocation, pin))
1313 Error =
"Cannot connect to default backend via UPnP. Wrong saved PIN?";
1324 QString loc =
"UPnPconnect() - ";
1329 LOG(VB_UPNP, LOG_INFO, loc + QString(
"Trying host at %1").arg(URL));
1333 GetMythDB()->SetDatabaseParams(dbParams);
1334 LOG(VB_UPNP, LOG_INFO, loc +
1342 LOG(VB_UPNP, LOG_ERR, loc +
"Wrong PIN?");
1346 LOG(VB_UPNP, LOG_ERR, loc +
error);
1354 URL = theURL.host();
1358 LOG(VB_UPNP, LOG_INFO,
"Trying default DB credentials at " + URL);
1360 GetMythDB()->SetDatabaseParams(dbParams);
1369 if (m_disableeventpopup)
1381 if (me->Message() ==
"VERSION_MISMATCH" && (1 == me->ExtraDataCount()))
1382 ShowVersionMismatchPopup(me->ExtraData(0).toUInt());
1383 else if (me->Message() ==
"CONNECTION_FAILURE")
1384 ShowConnectionFailurePopup(
false);
1385 else if (me->Message() ==
"PERSISTENT_CONNECTION_FAILURE")
1386 ShowConnectionFailurePopup(
true);
1387 else if (me->Message() ==
"CONNECTION_RESTABLISHED")
1388 HideConnectionFailurePopup();
1392 return QObject::event(e);
1402 if (m_lastCheck.isValid() && now < m_lastCheck)
1410 m_lastCheck = now.addMSecs(5000);
1412 QString description = (persistent) ?
1414 "The connection to the master backend "
1415 "server has gone away for some reason. "
1418 "Could not connect to the master backend server. Is "
1419 "it running? Is the IP address set for it in "
1420 "mythtv-setup correct?");
1422 QString message = QObject::tr(
"Could not connect to master backend");
1424 n.
SetId(m_registration);
1434 if (!m_lastCheck.isValid())
1438 n.
SetId(m_registration);
1442 m_lastCheck = QDateTime();
1447 if (m_mbeVersionPopup)
1452 "The server uses network protocol version %1, "
1453 "but this client only understands version %2. "
1454 "Make sure you are running compatible versions of "
1455 "the backend and frontend.")
1456 .arg(remote_version).arg(MYTH_PROTO_VERSION);
1465 LOG(VB_GENERAL, LOG_ERR,
LOC + message);
1477 qApp->processEvents(QEventLoop::AllEvents, 250);
1478 qApp->processEvents(QEventLoop::AllEvents, 250);
1487const std::array<QString, 13> GUISettingsCache::kSettings
1488{
"Theme",
"Language",
"Country",
"GuiHeight",
1489 "GuiOffsetX",
"GuiOffsetY",
"GuiWidth",
"RunFrontendInWindow",
1490 "AlwaysOnTop",
"HideMouseCursor",
"ThemePainter",
"libCECEnabled",
1491 "StartupScreenDelay" };
1494bool GUISettingsCache::save()
1496 QString cacheDirName =
GetConfDir() +
'/' + m_cachePath;
1497 QDir dir(cacheDirName);
1498 dir.mkpath(cacheDirName);
1501 for (
const auto & setting : kSettings)
1503 QString cacheValue = config.
GetValue(
"Settings/" + setting, QString());
1506 if (value != cacheValue)
1508 config.
SetValue(
"Settings/" + setting, value);
1519 return config.
Save();
1524void GUISettingsCache::loadOverrides()
const
1527 for (
const auto & setting : kSettings)
1531 QString value = config.GetValue(
"Settings/" + setting, QString());
1532 if (!value.isEmpty())
1541void GUISettingsCache::clearOverrides()
1544 for (
const auto & setting : kSettings)
1557 m_mbeVersionPopup =
nullptr;
1566 static bool WSAStarted =
false;
1570 int res = WSAStartup(MAKEWORD(2, 0), &wsadata);
1571 LOG(VB_SOCKET, LOG_INFO,
1572 QString(
"WSAStartup returned %1").arg(res));
1583 LOG(VB_GENERAL, LOG_EMERG,
LOC +
"Unable to allocate MythCoreContext");
1589 const bool promptForBackend,
1590 const bool disableAutoDiscovery,
1591 const bool ignoreDB)
1595 LOG(VB_GENERAL, LOG_EMERG,
LOC +
"Init() Out-of-memory");
1599 qRegisterMetaType<std::chrono::seconds>(
"std::chrono::seconds");
1600 qRegisterMetaType<std::chrono::milliseconds>(
"std::chrono::milliseconds");
1601 qRegisterMetaType<std::chrono::microseconds>(
"std::chrono::microseconds");
1608 QString warning = QObject::tr(
"mythtv-setup is deprecated.\n"
1609 "To set up MythTV, start mythbackend and use:\n"
1610 "http://localhost:6544/setupwizard");
1616 LOG(VB_GENERAL, LOG_EMERG,
1617 QString(
"Application binary version (%1) does not "
1618 "match libraries (%2)")
1621 QString warning = QObject::tr(
1622 "This application is not compatible "
1623 "with the installed MythTV libraries.");
1629 LOG(VB_GENERAL, LOG_WARNING, warning);
1637 QString home = getenv(
"HOME");
1640 home = getenv(
"LOCALAPPDATA");
1642 home = getenv(
"APPDATA");
1644 home = QString(
".");
1646 _putenv(QString(
"HOME=%1").arg(home).toLocal8Bit().constData());
1652 QString homedir = QDir::homePath();
1653 QString
confdir = qEnvironmentVariable(
"MYTHCONFDIR");
1654 if ((homedir.isEmpty() || homedir ==
"/") &&
1657 QString warning =
"Cannot locate your home directory."
1658 " Please set the environment variable HOME";
1664 LOG(VB_GENERAL, LOG_WARNING, warning);
1669 if (!
m_impl->
Init(gui, promptForBackend, disableAutoDiscovery, ignoreDB))
1702 LOG(VB_GENERAL, LOG_INFO,
"Waiting for threads to exit.");
1708 LOG(VB_GENERAL, LOG_INFO,
"Exiting");
1739#include "mythcontext.moc"
#define QAndroidJniEnvironment
#define ANDROID_EXCEPTION_CHECK
#define QAndroidJniObject
static Decision Prompt(DatabaseParams *dbParams, const QString &config_filename)
Structure containing the basic Database parameters.
QString m_dbName
database name
QString m_dbPassword
DB password.
std::chrono::seconds m_wolReconnect
seconds to wait for reconnect
QString m_localHostName
name used for loading/saving settings
bool m_localEnabled
true if localHostName is not default
bool IsValid(const QString &source=QString("Unknown")) const
bool m_dbHostPing
No longer used.
QString m_dbUserName
DB user name.
QString m_wolCommand
command to use for wake-on-lan
bool m_wolEnabled
true if wake-on-lan params are used
int m_dbPort
database port
int m_wolRetry
times to retry to reconnect
QString m_dbHostName
database server
void cancelPortCheck(void)
static bool prompt(bool force=false)
Ask the user for the language to use.
static bool testDBConnection()
Checks DB connection + login (login info via Mythcontext)
static MThreadPool * globalInstance(void)
Dialog asking for user confirmation.
bool event(QEvent *) override
static bool LoadDatabaseSettings()
Load database and host settings from XmlConfiguration::k_default_filename, or set some defaults.
QString m_dbHostCp
dbHostName backup
void OnCloseDialog() const
static void processEvents()
bool m_gui
Should this context use GUI elements?
static void LanguagePrompt()
bool checkPort(QString &host, int port, std::chrono::seconds timeLimit) const
Check if a port is open and sort out the link-local scope.
QString TestDBconnection(bool prompt=true)
Some quick sanity checks before opening a database connection.
bool PromptForDatabaseParams(const QString &error)
static bool DefaultUPnP(QString &Error)
Get the default backend from XmlConfiguration::kDefaultFilename, use UPnP to find it.
BackendSelection::Decision ChooseBackend(const QString &error)
Search for backends via UPnP, put up a UI for the user to choose one.
bool FindDatabase(bool prompt, bool noAutodetect)
Get database connection settings and test connectivity.
void ShowVersionMismatchPopup(uint remote_version)
bool Init(bool gui, bool promptForBackend, bool disableAutoDiscovery, bool ignoreDB)
static QString setLocalHostName(QString hostname)
static bool UPnPconnect(const DeviceLocation *backend, const QString &PIN)
Query a backend via UPnP for its database connection parameters.
void EnableDBerrors() const
bool FindDatabaseChoose(bool loaded, bool manualSelect, bool autoSelect)
Helper function for getting database connection settings and test connectivity.
static void ResetDatabase(const DatabaseParams &dbParams)
Called when the user changes the DB connection settings.
void VersionMismatchPopupClosed()
static int UPnPautoconf(std::chrono::milliseconds milliSeconds=2s)
If there is only a single UPnP backend, use it.
GUIStartup * m_guiStartup
void TempMainWindow()
Setup a minimal themed main window, and prompt for user's language.
MythConfirmationDialog * m_mbeVersionPopup
GUISettingsCache m_GUISettingsCache
void ShowConnectionFailurePopup(bool persistent)
void HideConnectionFailurePopup()
void SilenceDBerrors()
Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently.
QString m_masterhostname
master backend hostname
Startup context for MythTV.
CleanupFunction m_cleanup
This is used to destroy global state before main() returns.
QString m_appBinaryVersion
MythContext(QString binversion, bool needsBackend=false)
bool Init(bool gui=true, bool promptForBackend=false, bool disableAutoDiscovery=false, bool ignoreDB=false)
void SetDisableEventPopup(bool check)
Impl * m_impl
PIMPL idiom.
This class contains the runtime context for MythTV.
bool IsFrontend(void) const
is this process a frontend process
void ActivateSettingsCache(bool activate=true)
void ClearOverrideSettingForSession(const QString &key)
void SetLocalHostname(const QString &hostname)
QString GetSetting(const QString &key, const QString &defaultval="")
static int GetMasterServerPort(void)
Returns the Master Backend control port If no master server port has been defined in the database,...
MythPluginManager * GetPluginManager(void)
void OverrideSettingForSession(const QString &key, const QString &value)
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
bool IsBackend(void) const
is this process a backend process
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
bool IsWOLAllowed() const
void SaveLocaleDefaults(void)
int GetNumSetting(const QString &key, int defaultval=0)
void InitPower(bool Create=true)
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
This class is used as a container for messages.
static const Type kMythEventMessage
MythScreenStack * GetMainStack()
static MythMainWindow * getMainWindow(bool UseDB=true)
Return the existing main window, or create one.
void Init(bool MayReInit=true)
void UnRegister(void *from, int id, bool closeimemdiately=false)
Unregister the client.
int Register(void *from)
An application can register in which case it will be assigned a reusable screen, which can be modifie...
bool Queue(const MythNotification ¬ification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
void SetId(int Id)
Contains the application registration id.
void SetParent(void *Parent)
Contains the parent address. Required if id is set Id provided must match the parent address as provi...
void SetDuration(std::chrono::seconds Duration)
Contains a duration during which the notification will be displayed for. The duration is informative ...
bool config_plugin(const QString &plugname)
bool run_plugin(const QString &plugname)
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
A QElapsedTimer based timer to replace use of QTime as a timer.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
void start(void)
starts measuring elapsed time.
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
void Init(MythUIMenuCallbacks &cbs)
UPnPResultCode GetConnectionInfo(const QString &sPin, DatabaseParams *pParams, QString &sMsg)
Small class to handle TCP port checking and finding link-local context.
bool checkPort(QString &host, int port, std::chrono::milliseconds timeLimit=30s, bool linkLocalOnly=false)
Check if a port is open and sort out the link-local scope.
void cancelPortCheck(void)
Cancel the checkPort operation currently in progress.
static void PrintDebug(void)
Print out any leaks if that level of debugging is enabled.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
DeviceLocation * GetFirst(void)
Returns random entry in cache, returns nullptr when list is empty.
static SSDPCache * Instance()
SSDPCacheEntries * Find(const QString &sURI)
Finds the SSDPCacheEntries in the cache, returns nullptr when absent.
static const QString kBackendURI
void PerformSearch(const QString &sST, std::chrono::seconds timeout=2s)
Send a SSDP discover multicast datagram.
static void Init(QObject *parent=nullptr)
static const QString kDefaultUSN
static const QString kDefaultWOL
static const QString kDefaultDB
QString GetValue(const QString &setting)
static constexpr auto kDefaultFilename
void SetValue(const QString &setting, bool value)
static const QString kDefaultPIN
GUISettingsCache()=default
GUISettingsCache(const QString &cache_filename, QString cache_path)
static const std::array< QString, 13 > kSettings
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
@ GENERIC_EXIT_SOCKET_ERROR
Socket error.
void logStop(void)
Entry point for stopping logging for an application.
static constexpr const char * MYTH_APPNAME_MYTHTV_SETUP
static void plugin_cb(const QString &cmd)
static void exec_program_cb(const QString &cmd)
static void exec_program_tv_cb(const QString &cmd)
static void configplugin_cb(const QString &cmd)
static const QString sLocation
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()
bool WaitFor(MythConfirmationDialog *dialog)
Blocks until confirmation dialog exits.
void InitializeMythDirs(void)
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythNotificationCenter * GetNotificationCenter(void)
bool HasMythMainWindow(void)
MythMainWindow * GetMythMainWindow(void)
void DestroyMythMainWindow(void)
bool MythWakeup(const QString &wakeUpCommand, uint flags, std::chrono::seconds timeout)
int intResponse(const QString &query, int def)
In an interactive shell, prompt the user to input a number.
QString getResponse(const QString &query, const QString &def)
In an interactive shell, prompt the user to input a string.
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
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
MythUIHelper * GetMythUI()
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
@ UPnPResult_ActionNotAuthorized