12#include <QCoreApplication>
22#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
23#include <QtAndroidExtras>
25#include <QJniEnvironment>
27#define QAndroidJniEnvironment QJniEnvironment
28#define QAndroidJniObject QJniObject
49#include "libmythbase/mythversion.h"
70#define LOC QString("MythContext: ")
80 : m_cachePath(
std::move(cache_path))
82 m_cacheFilename = m_cachePath +
'/' + cache_filename;
83 if (m_cachePath.isEmpty() || cache_filename.isEmpty())
85 m_cacheFilename = m_cachePath = QString();
90 void loadOverrides()
const;
91 static void clearOverrides();
94 QString m_cacheFilename {
"cache/contextcache.xml"};
95 QString m_cachePath {
"cache"};
111 bool promptForBackend,
112 bool disableAutoDiscovery,
133 static int UPnPautoconf(std::chrono::milliseconds milliSeconds = 2s);
137 bool checkPort(QString &host,
int port, std::chrono::seconds timeLimit)
const;
141 bool event(QEvent* )
override;
183 QStringList tokens = cmd.simplified().split(
" ");
186 bool cardidok =
false;
187 int wantcardid = tokens[0].toInt(&cardidok, 10);
189 if (cardidok && wantcardid > 0)
191 strlist << QString(
"LOCK_TUNER %1").arg(wantcardid);
192 s = s.replace(0, tokens[0].length() + 1,
"");
196 strlist <<
"LOCK_TUNER";
200 int cardid = strlist[0].toInt();
204 s = s.arg(qPrintable(strlist[1]),
205 qPrintable(strlist[2]),
206 qPrintable(strlist[3]));
210 strlist = QStringList(QString(
"FREE_TUNER %1").arg(cardid));
221 label = QObject::tr(
"Could not find specified tuner (%1).")
226 label = QObject::tr(
"Specified tuner (%1) is already in use.")
232 label = QObject::tr(
"All tuners are currently in use. If you want "
233 "to watch TV, you can cancel one of the "
234 "in-progress recordings from the delete menu");
237 LOG(VB_GENERAL, LOG_ALERT, QString(
"exec_program_tv: ") + label);
252 QObject::tr(
"Failed to configure plugin"));
266 QObject::tr(
"%1 failed to run for some reason").arg(cmd));
276 : m_loop(new QEventLoop(this))
324 if (m_guiStartup && !m_guiStartup->m_Exit)
329 mainStack->
PopScreen(m_guiStartup,
false);
330 m_guiStartup =
nullptr;
358 return checker.
checkPort(host, port, timeLimit);
363 const bool promptForBackend,
364 const bool disableAutoDiscovery,
371 m_GUISettingsCache.loadOverrides();
375 m_needsBackend =
true;
383 if (!ignoreDB && !FindDatabase(promptForBackend, disableAutoDiscovery))
406 mainStack->
PopScreen(m_guiStartup,
false);
407 m_guiStartup=
nullptr;
442 if (DefaultUPnP(failure))
443 autoSelect = manualSelect =
false;
445 if (!failure.isEmpty())
446 LOG(VB_GENERAL, LOG_ALERT, failure);
448 failure = TestDBconnection(loaded);
449 if (failure.isEmpty())
451 if (m_guiStartup && m_guiStartup->m_Exit)
453 if (m_guiStartup && m_guiStartup->m_Search)
460 int count = UPnPautoconf();
463 failure = QObject::tr(
"No UPnP backends found",
"Backend Setup");
467 failure = TestDBconnection();
468 if (failure.isEmpty())
470 if (m_guiStartup && m_guiStartup->m_Exit)
475 manualSelect |= (count > 1 || count == -1);
477 if (m_guiStartup && m_guiStartup->m_Search)
481 manualSelect &= m_gui;
484 bool haveDbInfo {
false};
490 switch (ChooseBackend(failure))
495 manualSelect =
false;
499 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - failed");
511 || !PromptForDatabaseParams(failure))
513 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - failed");
517 failure = TestDBconnection();
518 haveDbInfo = failure.isEmpty();
519 if (!failure.isEmpty())
520 LOG(VB_GENERAL, LOG_ALERT, failure);
521 if (m_guiStartup && m_guiStartup->m_Exit)
523 if (m_guiStartup && m_guiStartup->m_Search)
525 if (m_guiStartup && m_guiStartup->m_Setup)
547 bool manualSelect = prompt && !noAutodetect;
550 bool loaded = LoadDatabaseSettings();
557 bool autoSelect = !manualSelect && !loaded && !noAutodetect;
559 if (!FindDatabaseChoose(loaded, manualSelect, autoSelect))
562 LOG(VB_GENERAL, LOG_DEBUG,
"FindDatabase() - Success!");
571 GetMythDB()->SaveDatabaseParams(dbParams, !loaded || dbParamsFromFile != dbParams);
573 ResetDatabase(dbParams);
608 GetMythDB()->SetDatabaseParams(dbParams);
615 hostname ==
"my-unique-identifier-goes-here")
617 LOG(VB_GENERAL, LOG_INFO,
"Empty LocalHostName. This is typical.");
618 hostname = QHostInfo::localHostName();
623 LOG(VB_GENERAL, LOG_ALERT,
624 "MCP: Error, could not determine host name." +
ENO);
627#define ANDROID_EXCEPTION_CHECK \
628 if (env->ExceptionCheck()) \
630 env->ExceptionClear(); \
637 bool exception=
false;
640#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
643 QJniObject activity = QNativeInterface::QAndroidApplication::context();
647 (
"getApplicationContext",
"()Landroid/content/Context;");
650 (
"getContentResolver",
"()Landroid/content/ContentResolver;");
653 (
"android/provider/Settings$Secure",
"getString",
654 "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
655 contentR.object<jobject>(),
656 myID.object<jstring>());
659 LOG(VB_GENERAL, LOG_ALERT,
660 "Java exception looking for android id");
662 hostname = QString(
"android-%1").arg(androidId.toString());
668 LOG(VB_GENERAL, LOG_INFO, QString(
"Using a profile name of: '%1' (Usually the "
669 "same as this host's name.)")
679 if (m_loop && m_loop->isRunning())
692 bool accepted =
false;
699 if (!
error.isEmpty())
714 if (!m_loop->isRunning())
729 std::this_thread::sleep_for(1s);
731 std::cout << std::endl <<
error.toLocal8Bit().constData() << std::endl << std::endl;
732 response =
getResponse(
"Would you like to configure the database "
735 if (!response.startsWith(
'y', Qt::CaseInsensitive))
740 response =
getResponse(
"Should I test connectivity to this host "
741 "using the ping command?",
"yes");
742 params.
m_dbHostPing = response.startsWith(
'y', Qt::CaseInsensitive);
754 "(if empty, the local host name "
759 response =
getResponse(
"Would you like to use Wake-On-LAN to retry "
760 "database connections?",
762 params.
m_wolEnabled = response.startsWith(
'y', Qt::CaseInsensitive);
767 std::chrono::seconds(
intResponse(
"Seconds to wait for "
776 accepted =
GetMythDB()->SaveDatabaseParams(params,
false);
800 enum startupStates : std::uint8_t {
808 } startupState = st_start;
810 static const std::array<const QString, 7> kGuiStatuses
811 {
"start",
"dbAwake",
"dbStarted",
"dbConnects",
"beWOL",
"beAwake",
"success"};
814 auto msStartupScreenDelay = std::chrono::duration_cast<std::chrono::milliseconds>(secondsStartupScreenDelay);
820 if (dbParams.
m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
827 std::chrono::seconds wakeupTime = 3s;
833 startupState = st_start;
837 startupState = st_dbAwake;
839 attempts = std::max(attempts, 6);
845 std::chrono::seconds progressTotal = wakeupTime * attempts;
847 if (m_guiStartup && !m_guiStartup->m_Exit)
848 m_guiStartup->setTotal(progressTotal);
850 QString beWOLCmd = QString();
851 QString backendIP = QString();
853 QString masterserver;
855 for (
int attempt = 0;
856 attempt < attempts && startupState != st_success;
863 LOG(VB_GENERAL, LOG_INFO,
864 QString(
"Start up testing connections. DB %1, BE %2, attempt %3, status %4, Delay: %5")
865 .arg(host, backendIP, QString::number(attempt),
866 kGuiStatuses[startupState],
867 QString::number(msStartupScreenDelay.count())) );
869 std::chrono::seconds useTimeout = wakeupTime;
873 if (m_gui && !m_guiStartup)
875 if (msStartupScreenDelay==0ms || timer.hasExpired(msStartupScreenDelay.count()))
879 m_guiStartup->setTotal(progressTotal);
882 if (m_guiStartup && !m_guiStartup->m_Exit)
885 m_guiStartup->setStatusState(kGuiStatuses[startupState]);
886 m_guiStartup->setMessageState(
"empty");
889 switch (startupState)
896 if (!checkPort(host, port, useTimeout))
899 startupState = st_dbAwake;
902 if (!checkPort(host, port, useTimeout))
904 startupState = st_dbStarted;
912 GetMythDB()->SetDatabaseParams(dbParams);
915 ResetDatabase(dbParams);
918 for (std::chrono::seconds temp = 0s; temp < useTimeout * 2 ; temp++)
921 std::this_thread::sleep_for(500ms);
925 startupState = st_dbConnects;
931 if (!beWOLCmd.isEmpty())
934 (
"WOLbackendReconnectWaitTime", 0s);
936 (
"WOLbackendConnectRetry", 0);
937 useTimeout = wakeupTime;
938 if (m_gui && !m_guiStartup && attempt == 0)
940 progressTotal = wakeupTime * attempts;
941 if (m_guiStartup && !m_guiStartup->m_Exit)
942 m_guiStartup->setTotal(progressTotal);
943 startupState = st_beWOL;
948 startupState = st_success;
952 (
"MasterServerName");
954 (
"BackendServerAddr", masterserver);
958 if (!beWOLCmd.isEmpty())
962 if (!checkPort(backendIP, backendPort, useTimeout))
965 startupState = st_beAwake;
968 if (!checkPort(backendIP, backendPort, useTimeout))
970 startupState = st_success;
978 if (m_guiStartup->m_Exit
979 || m_guiStartup->m_Setup
980 || m_guiStartup->m_Search
981 || m_guiStartup->m_Retry)
986 if (startupState == st_success)
989 QString stateMsg = kGuiStatuses[startupState];
990 stateMsg.append(
"Fail");
991 LOG(VB_GENERAL, LOG_INFO,
992 QString(
"Start up failure. host %1, status %2")
993 .arg(host, stateMsg));
995 if (m_gui && !m_guiStartup)
999 m_guiStartup->setTotal(progressTotal);
1003 && !m_guiStartup->m_Exit
1004 && !m_guiStartup->m_Setup
1005 && !m_guiStartup->m_Search
1006 && !m_guiStartup->m_Retry)
1008 m_guiStartup->updateProgress(
true);
1009 m_guiStartup->setStatusState(stateMsg);
1010 m_guiStartup->setMessageState(
"makeselection");
1014 while (m_guiStartup && m_guiStartup->m_Retry);
1016 if (startupState < st_dbAwake)
1018 LOG(VB_GENERAL, LOG_WARNING, QString(
"Pinging to %1 failed, database will be unavailable").arg(host));
1021 "Cannot find (ping) database host %1 on the network",
1023 return err.arg(host);
1026 if (startupState < st_dbConnects)
1029 return QObject::tr(
"Cannot login to database",
"Backend Setup");
1032 if (startupState < st_success)
1034 return QObject::tr(
"Cannot connect to backend",
"Backend Setup");
1039 ResetDatabase(dbParams);
1058 m_guiStartup =
new GUIStartup(mainStack, m_loop);
1059 if (!m_guiStartup->Create())
1061 delete m_guiStartup;
1062 m_guiStartup =
nullptr;
1066 mainStack->
AddScreen(m_guiStartup,
false);
1094 GetMythDB()->SetDatabaseParams(dbParams);
1102 if (dbParams.
m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
1105 GetMythDB()->SetDatabaseParams(dbParams);
1126 db->GetDBManager()->CloseDatabases();
1127 db->SetDatabaseParams(dbParams);
1128 db->ClearSettingsCache();
1140 if (!
error.isEmpty())
1142 LOG(VB_GENERAL, LOG_ERR, QString(
"Error: %1").arg(
error));
1146 LOG(VB_GENERAL, LOG_INFO,
"Putting up the UPnP backend chooser");
1151 GetMythDB()->SetDatabaseParams(dbParams);
1166 auto seconds = duration_cast<std::chrono::seconds>(milliSeconds);
1167 LOG(VB_GENERAL, LOG_INFO, QString(
"UPNP Search %1 secs")
1168 .arg(seconds.count()));
1176 while (totalTime.
elapsed() < milliSeconds)
1179 auto ttl = milliSeconds - totalTime.
elapsed();
1180 if ((searchTime.
elapsed() > 249ms) && (ttl > 1s))
1182 auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1183 LOG(VB_GENERAL, LOG_INFO, QString(
"UPNP Search %1 secs")
1184 .arg(ttlSeconds.count()));
1194 LOG(VB_GENERAL, LOG_INFO,
"No UPnP backends found");
1198 int count = backends->
Count();
1201 LOG(VB_GENERAL, LOG_INFO,
1202 QString(
"Found %1 UPnP backends").arg(count));
1206 LOG(VB_GENERAL, LOG_ERR,
1207 "No UPnP backends found, but SSDPCache::Instance()->Find() not NULL");
1223 int ret = (UPnPconnect(BE, QString())) ? 1 : -1;
1237 static const QString loc =
"DefaultUPnP() - ";
1250 LOG(VB_UPNP, LOG_INFO, loc +
"No default UPnP backend");
1254 LOG(VB_UPNP, LOG_INFO,
1256 QString(
" has default PIN '%1' and host USN: %2").arg(pin, usn));
1260 std::chrono::milliseconds timeout_ms {2s};
1261 auto timeout_s = duration_cast<std::chrono::seconds>(timeout_ms);
1262 LOG(VB_GENERAL, LOG_INFO, loc + QString(
"UPNP Search up to %1 secs")
1263 .arg(timeout_s.count()));
1275 while (totalTime.
elapsed() < timeout_ms)
1283 auto ttl = timeout_ms - totalTime.
elapsed();
1284 if ((searchTime.
elapsed() > 249ms) && (ttl > 1s))
1286 auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1287 LOG(VB_GENERAL, LOG_INFO, loc + QString(
"UPNP Search up to %1 secs")
1288 .arg(ttlSeconds.count()));
1296 if (!devicelocation)
1298 Error =
"Cannot find default UPnP backend";
1302 if (UPnPconnect(devicelocation, pin))
1309 Error =
"Cannot connect to default backend via UPnP. Wrong saved PIN?";
1320 QString loc =
"UPnPconnect() - ";
1325 LOG(VB_UPNP, LOG_INFO, loc + QString(
"Trying host at %1").arg(URL));
1329 GetMythDB()->SetDatabaseParams(dbParams);
1330 LOG(VB_UPNP, LOG_INFO, loc +
1338 LOG(VB_UPNP, LOG_ERR, loc +
"Wrong PIN?");
1342 LOG(VB_UPNP, LOG_ERR, loc +
error);
1350 URL = theURL.host();
1354 LOG(VB_UPNP, LOG_INFO,
"Trying default DB credentials at " + URL);
1356 GetMythDB()->SetDatabaseParams(dbParams);
1365 if (m_disableeventpopup)
1377 if (me->Message() ==
"VERSION_MISMATCH" && (1 == me->ExtraDataCount()))
1378 ShowVersionMismatchPopup(me->ExtraData(0).toUInt());
1379 else if (me->Message() ==
"CONNECTION_FAILURE")
1380 ShowConnectionFailurePopup(
false);
1381 else if (me->Message() ==
"PERSISTENT_CONNECTION_FAILURE")
1382 ShowConnectionFailurePopup(
true);
1383 else if (me->Message() ==
"CONNECTION_RESTABLISHED")
1384 HideConnectionFailurePopup();
1388 return QObject::event(e);
1398 if (m_lastCheck.isValid() && now < m_lastCheck)
1406 m_lastCheck = now.addMSecs(5000);
1408 QString description = (persistent) ?
1410 "The connection to the master backend "
1411 "server has gone away for some reason. "
1414 "Could not connect to the master backend server. Is "
1415 "it running? Is the IP address set for it in "
1416 "mythtv-setup correct?");
1418 QString message = QObject::tr(
"Could not connect to master backend");
1420 n.
SetId(m_registration);
1430 if (!m_lastCheck.isValid())
1434 n.
SetId(m_registration);
1438 m_lastCheck = QDateTime();
1443 if (m_mbeVersionPopup)
1448 "The server uses network protocol version %1, "
1449 "but this client only understands version %2. "
1450 "Make sure you are running compatible versions of "
1451 "the backend and frontend.")
1452 .arg(remote_version).arg(MYTH_PROTO_VERSION);
1461 LOG(VB_GENERAL, LOG_ERR,
LOC + message);
1473 qApp->processEvents(QEventLoop::AllEvents, 250);
1474 qApp->processEvents(QEventLoop::AllEvents, 250);
1483const std::array<QString, 13> GUISettingsCache::kSettings
1484{
"Theme",
"Language",
"Country",
"GuiHeight",
1485 "GuiOffsetX",
"GuiOffsetY",
"GuiWidth",
"RunFrontendInWindow",
1486 "AlwaysOnTop",
"HideMouseCursor",
"ThemePainter",
"libCECEnabled",
1487 "StartupScreenDelay" };
1490bool GUISettingsCache::save()
1492 QString cacheDirName =
GetConfDir() +
'/' + m_cachePath;
1493 QDir dir(cacheDirName);
1494 dir.mkpath(cacheDirName);
1497 for (
const auto & setting : kSettings)
1499 QString cacheValue = config.
GetValue(
"Settings/" + setting, QString());
1502 if (value != cacheValue)
1504 config.
SetValue(
"Settings/" + setting, value);
1515 return config.
Save();
1520void GUISettingsCache::loadOverrides()
const
1523 for (
const auto & setting : kSettings)
1527 QString value = config.GetValue(
"Settings/" + setting, QString());
1528 if (!value.isEmpty())
1537void GUISettingsCache::clearOverrides()
1540 for (
const auto & setting : kSettings)
1553 m_mbeVersionPopup =
nullptr;
1562 static bool WSAStarted =
false;
1566 int res = WSAStartup(MAKEWORD(2, 0), &wsadata);
1567 LOG(VB_SOCKET, LOG_INFO,
1568 QString(
"WSAStartup returned %1").arg(res));
1579 LOG(VB_GENERAL, LOG_EMERG,
LOC +
"Unable to allocate MythCoreContext");
1585 const bool promptForBackend,
1586 const bool disableAutoDiscovery,
1587 const bool ignoreDB)
1591 LOG(VB_GENERAL, LOG_EMERG,
LOC +
"Init() Out-of-memory");
1595 qRegisterMetaType<std::chrono::seconds>(
"std::chrono::seconds");
1596 qRegisterMetaType<std::chrono::milliseconds>(
"std::chrono::milliseconds");
1597 qRegisterMetaType<std::chrono::microseconds>(
"std::chrono::microseconds");
1604 QString warning = QObject::tr(
"mythtv-setup is deprecated.\n"
1605 "To set up MythTV, start mythbackend and use:\n"
1606 "http://localhost:6544/setupwizard");
1612 LOG(VB_GENERAL, LOG_EMERG,
1613 QString(
"Application binary version (%1) does not "
1614 "match libraries (%2)")
1617 QString warning = QObject::tr(
1618 "This application is not compatible "
1619 "with the installed MythTV libraries.");
1625 LOG(VB_GENERAL, LOG_WARNING, warning);
1633 QString home = getenv(
"HOME");
1636 home = getenv(
"LOCALAPPDATA");
1638 home = getenv(
"APPDATA");
1640 home = QString(
".");
1642 _putenv(QString(
"HOME=%1").arg(home).toLocal8Bit().constData());
1648 QString homedir = QDir::homePath();
1649 QString
confdir = qEnvironmentVariable(
"MYTHCONFDIR");
1650 if ((homedir.isEmpty() || homedir ==
"/") &&
1653 QString warning =
"Cannot locate your home directory."
1654 " Please set the environment variable HOME";
1660 LOG(VB_GENERAL, LOG_WARNING, warning);
1665 if (!
m_impl->
Init(gui, promptForBackend, disableAutoDiscovery, ignoreDB))
1698 LOG(VB_GENERAL, LOG_INFO,
"Waiting for threads to exit.");
1704 LOG(VB_GENERAL, LOG_INFO,
"Exiting");
1735#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