MythTV  master
mythcontext.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cmath>
3 #include <iostream>
4 #include <queue>
5 #include <thread>
6 #include <unistd.h> // for usleep(), gethostname
7 #include <vector>
8 
9 #include <QCoreApplication>
10 #include <QDateTime>
11 #include <QDebug>
12 #include <QDir>
13 #include <QEventLoop>
14 #include <QFileInfo>
15 #include <QHostInfo>
16 #include <QMutex>
17 #include <QTcpSocket>
18 #ifdef Q_OS_ANDROID
19 #include <QtAndroidExtras>
20 #endif
21 
22 #ifdef _WIN32
23 #include "libmythbase/compat.h"
24 #endif
25 #include "libmythbase/dbutil.h"
26 #include "libmythbase/exitcodes.h"
27 #include "libmythbase/mythdate.h"
28 #include "libmythbase/mythdb.h"
29 #include "libmythbase/mythdirs.h"
30 #include "libmythbase/mythevent.h"
33 #include "libmythbase/mythplugin.h"
38 #include "libmythbase/remotefile.h"
40 #include "libmythui/mythimage.h"
42 #include "libmythui/mythuihelper.h"
44 #include "libmythupnp/upnp.h"
45 
46 #include "backendselect.h"
47 #include "dbsettings.h"
48 #include "guistartup.h"
49 #include "langsettings.h"
50 #include "mythcontext.h"
51 #include "mythmediamonitor.h"
52 
53 #define LOC QString("MythContext: ")
54 
55 #if QT_VERSION < QT_VERSION_CHECK(5,10,0)
56 #define qEnvironmentVariable getenv
57 #endif
58 
59 MythContext *gContext = nullptr;
60 
61 static const QString sLocation = "MythContext";
62 
63 class MythContextPrivate : public QObject
64 {
65  friend class MythContextSlotHandler;
66 
67  public:
68  explicit MythContextPrivate(MythContext *lparent);
69  ~MythContextPrivate() override;
70 
71  bool Init (bool gui,
72  bool promptForBackend,
73  bool disableAutoDiscovery,
74  bool ignoreDB);
75  bool FindDatabase(bool prompt, bool noAutodetect);
76 
77  void TempMainWindow(bool languagePrompt = true);
78  void EndTempWindow(void);
79 
80  bool LoadDatabaseSettings(void);
81  bool SaveDatabaseParams(const DatabaseParams &params, bool force);
82 
83  bool PromptForDatabaseParams(const QString &error);
84  QString TestDBconnection(bool prompt=true);
85  void SilenceDBerrors(void);
86  void EnableDBerrors(void);
87  void ResetDatabase(void) const;
88 
89  int ChooseBackend(const QString &error);
90  int UPnPautoconf(std::chrono::milliseconds milliSeconds = 2s);
91  bool DefaultUPnP(QString& Error);
92  bool UPnPconnect(const DeviceLocation *backend, const QString &PIN);
93  void ShowGuiStartup(void);
94  bool checkPort(QString &host, int port, std::chrono::seconds timeLimit) const;
95  static void processEvents(void);
96  bool saveSettingsCache(void);
97  void loadSettingsCacheOverride(void) const;
98  static void clearSettingsCacheOverride(void);
99 
100 
101  protected:
102  bool event(QEvent* /*e*/) override; // QObject
103 
104  void ShowConnectionFailurePopup(bool persistent);
105  void HideConnectionFailurePopup(void);
106 
107  void ShowVersionMismatchPopup(uint remote_version);
108 
109  public slots:
110  void OnCloseDialog();
111 
112  public:
113  MythContext *m_parent {nullptr};
114 
116  bool m_gui {false};
117 
119 
121  QString m_dbHostCp;
122 
124 
125  bool m_disableeventpopup {false};
126 
127  MythUIHelper *m_ui {nullptr};
130  QEventLoop *m_loop {nullptr};
131  bool m_needsBackend {false};
132  bool m_settingsCacheDirty {false};
133 
134  private:
136  int m_registration {-1};
137  QDateTime m_lastCheck;
138  QTcpSocket *m_socket {nullptr};
139  static const std::vector<QString> kSettingsToSave;
140 };
141 
142 static void exec_program_cb(const QString &cmd)
143 {
144  myth_system(cmd);
145 }
146 
147 static void exec_program_tv_cb(const QString &cmd)
148 {
149  QString s = cmd;
150  QStringList tokens = cmd.simplified().split(" ");
151  QStringList strlist;
152 
153  bool cardidok = false;
154  int wantcardid = tokens[0].toInt(&cardidok, 10);
155 
156  if (cardidok && wantcardid > 0)
157  {
158  strlist << QString("LOCK_TUNER %1").arg(wantcardid);
159  s = s.replace(0, tokens[0].length() + 1, "");
160  }
161  else
162  strlist << "LOCK_TUNER";
163 
165  int cardid = strlist[0].toInt();
166 
167  if (cardid >= 0)
168  {
169  s = s.arg(qPrintable(strlist[1]),
170  qPrintable(strlist[2]),
171  qPrintable(strlist[3]));
172 
173  myth_system(s);
174 
175  strlist = QStringList(QString("FREE_TUNER %1").arg(cardid));
177  }
178  else
179  {
180  QString label;
181 
182  if (cardidok)
183  {
184  if (cardid == -1)
185  {
186  label = QObject::tr("Could not find specified tuner (%1).")
187  .arg(wantcardid);
188  }
189  else
190  {
191  label = QObject::tr("Specified tuner (%1) is already in use.")
192  .arg(wantcardid);
193  }
194  }
195  else
196  {
197  label = QObject::tr("All tuners are currently in use. If you want "
198  "to watch TV, you can cancel one of the "
199  "in-progress recordings from the delete menu");
200  }
201 
202  LOG(VB_GENERAL, LOG_ALERT, QString("exec_program_tv: ") + label);
203 
204  ShowOkPopup(label);
205  }
206 }
207 
208 static void configplugin_cb(const QString &cmd)
209 {
211  if (!pmanager)
212  return;
213 
214  if (GetNotificationCenter() && pmanager->config_plugin(cmd.trimmed()))
215  {
217  QObject::tr("Failed to configure plugin"));
218  }
219 }
220 
221 static void plugin_cb(const QString &cmd)
222 {
224  if (!pmanager)
225  return;
226 
227  if (GetNotificationCenter() && pmanager->run_plugin(cmd.trimmed()))
228  {
229  ShowNotificationError(QObject::tr("Plugin failure"),
230  sLocation,
231  QObject::tr("%1 failed to run for some reason").arg(cmd));
232  }
233 }
234 
235 static void eject_cb(void)
236 {
238 }
239 
241  : m_parent(lparent),
242  m_sh(new MythContextSlotHandler(this))
243 {
244  m_loop = new QEventLoop(this);
246 }
247 
249 {
250  delete m_pConfig;
252  {
254  }
255 
256  delete m_loop;
257 
258  if (m_ui)
259  DestroyMythUI();
260  if (m_sh)
261  m_sh->deleteLater();
262 }
263 
274 void MythContextPrivate::TempMainWindow(bool languagePrompt)
275 {
276  if (HasMythMainWindow())
277  return;
278 
279  SilenceDBerrors();
280 
281 #ifdef Q_OS_DARWIN
282  // Qt 4.4 has window-focus problems
283  gCoreContext->OverrideSettingForSession("RunFrontendInWindow", "1");
284 #endif
285  GetMythUI()->Init();
286  MythMainWindow *mainWindow = MythMainWindow::getMainWindow(false);
287  mainWindow->Init();
288 
289  if (languagePrompt)
290  {
291  // ask user for language settings
293  MythTranslation::load("mythfrontend");
294  }
295 }
296 
298 {
299  if (HasMythMainWindow())
300  {
302  {
304  if (mainStack) {
305  mainStack->PopScreen(m_guiStartup, false);
306  m_guiStartup = nullptr;
307  }
308  }
309  }
310  EnableDBerrors();
311 }
312 
322 bool MythContextPrivate::checkPort(QString &host, int port, std::chrono::seconds timeLimit) const
323 {
324  PortChecker checker;
325  if (m_guiStartup)
327  return checker.checkPort(host, port, timeLimit);
328 }
329 
330 
331 bool MythContextPrivate::Init(const bool gui,
332  const bool promptForBackend,
333  const bool disableAutoDiscovery,
334  const bool ignoreDB)
335 {
336  gCoreContext->GetDB()->IgnoreDatabase(ignoreDB);
337  m_gui = gui;
339 
340  if (gCoreContext->IsFrontend())
341  m_needsBackend = true;
342 
343  // We don't have a database yet, so lets use the config.xml file.
344  m_pConfig = new XmlConfiguration("config.xml");
345 
346  // Creates screen saver control if we will have a GUI
347  if (gui)
348  m_ui = GetMythUI();
349 
350  // ---- database connection stuff ----
351 
352  if (!ignoreDB && !FindDatabase(promptForBackend, disableAutoDiscovery))
353  {
354  EndTempWindow();
355  return false;
356  }
357 
358  // ---- keep all DB-using stuff below this line ----
359 
360  // Prompt for language if this is a first time install and
361  // we didn't already do so.
362  if (m_gui && !gCoreContext->GetDB()->HaveSchema())
363  {
364  TempMainWindow(false);
366  MythTranslation::load("mythfrontend");
367  }
370 
371  // Close GUI Startup Window.
372  if (m_guiStartup) {
374  if (mainStack)
375  mainStack->PopScreen(m_guiStartup, false);
376  m_guiStartup=nullptr;
377  }
378  EndTempWindow();
379 
380  if (gui)
381  {
382  MythUIMenuCallbacks cbs {};
384  cbs.exec_program_tv = exec_program_tv_cb;
385  cbs.configplugin = configplugin_cb;
386  cbs.plugin = plugin_cb;
387  cbs.eject = eject_cb;
388 
389  m_ui->Init(cbs);
390  }
391 
392  return true;
393 }
394 
407 bool MythContextPrivate::FindDatabase(bool prompt, bool noAutodetect)
408 {
409  // We can only prompt if autodiscovery is enabled..
410  bool manualSelect = prompt && !noAutodetect;
411 
412  QString failure;
413 
414  // 1. Either load config.xml or use sensible "localhost" defaults:
415  bool loaded = LoadDatabaseSettings();
416  DatabaseParams dbParamsFromFile = m_dbParams;
417 
418  // In addition to the UI chooser, we can also try to autoSelect later,
419  // but only if we're not doing manualSelect and there was no
420  // valid config.xml
421  bool autoSelect = !manualSelect && !loaded && !noAutodetect;
422 
423  // 2. If the user isn't forcing up the chooser UI, look for a default
424  // backend in config.xml, then test DB settings we've got so far:
425  if (!manualSelect)
426  {
427  // config.xml may contain a backend host UUID and PIN.
428  // If so, try to AutoDiscover UPnP server, and use its DB settings:
429 
430  if (DefaultUPnP(failure)) // Probably a valid backend,
431  autoSelect = manualSelect = false; // so disable any further UPnP
432  else
433  if (!failure.isEmpty())
434  LOG(VB_GENERAL, LOG_ALERT, failure);
435 
436  failure = TestDBconnection(loaded);
437  if (failure.isEmpty())
438  goto DBfound;
440  return false;
442  autoSelect=true;
443  }
444 
445  // 3. Try to automatically find the single backend:
446  if (autoSelect)
447  {
448  int count = UPnPautoconf();
449 
450  if (count == 0)
451  failure = QObject::tr("No UPnP backends found", "Backend Setup");
452 
453  if (count == 1)
454  {
455  failure = TestDBconnection();
456  if (failure.isEmpty())
457  goto DBfound;
459  return false;
460  }
461 
462  // Multiple BEs, or needs PIN.
463  manualSelect |= (count > 1 || count == -1);
464  // Search requested
466  manualSelect=true;
467  }
468 
469  manualSelect &= m_gui; // no interactive command-line chooser yet
470 
471  // Queries the user for the DB info
472  do
473  {
474  if (manualSelect)
475  {
476  // Get the user to select a backend from a possible list:
477  auto d = (BackendSelection::Decision)ChooseBackend(failure);
478  switch (d)
479  {
481  break;
483  manualSelect = false;
484  break;
486  goto NoDBfound;
487  }
488  }
489 
490  if (!manualSelect)
491  {
492  if (!PromptForDatabaseParams(failure))
493  goto NoDBfound;
494  }
495  failure = TestDBconnection();
496  if (!failure.isEmpty())
497  LOG(VB_GENERAL, LOG_ALERT, failure);
499  return false;
501  manualSelect=true;
503  manualSelect=false;
504  }
505  while (!failure.isEmpty());
506 
507 DBfound:
508  LOG(VB_GENERAL, LOG_DEBUG, "FindDatabase() - Success!");
509  // If we got the database from UPNP then the wakeup settings are lost.
510  // Restore them.
511  m_dbParams.m_wolEnabled = dbParamsFromFile.m_wolEnabled;
512  m_dbParams.m_wolReconnect = dbParamsFromFile.m_wolReconnect;
513  m_dbParams.m_wolRetry = dbParamsFromFile.m_wolRetry;
514  m_dbParams.m_wolCommand = dbParamsFromFile.m_wolCommand;
515 
517  !loaded || m_dbParams.m_forceSave ||
518  dbParamsFromFile != m_dbParams);
519  EnableDBerrors();
520  ResetDatabase();
521  return true;
522 
523 NoDBfound:
524  LOG(VB_GENERAL, LOG_DEBUG, "FindDatabase() - failed");
525  return false;
526 }
527 
532 {
533  // try new format first
535 
536  m_dbParams.m_localHostName = m_pConfig->GetValue("LocalHostName", "");
539  m_dbParams.m_dbUserName = m_pConfig->GetValue(kDefaultDB + "UserName", "");
540  m_dbParams.m_dbPassword = m_pConfig->GetValue(kDefaultDB + "Password", "");
541  m_dbParams.m_dbName = m_pConfig->GetValue(kDefaultDB + "DatabaseName", "");
543 
545  m_pConfig->GetBoolValue(kDefaultWOL + "Enabled", false);
547  m_pConfig->GetDuration<std::chrono::seconds>(kDefaultWOL + "SQLReconnectWaitTime", 0s);
549  m_pConfig->GetValue(kDefaultWOL + "SQLConnectRetry", 5);
551  m_pConfig->GetValue(kDefaultWOL + "Command", "");
552 
553  bool ok = m_dbParams.IsValid("config.xml");
554  if (!ok) // if new format fails, try legacy format
555  {
558  kDefaultMFE + "DBHostName", "");
560  kDefaultMFE + "DBUserName", "");
562  kDefaultMFE + "DBPassword", "");
564  kDefaultMFE + "DBName", "");
566  kDefaultMFE + "DBPort", 0);
567  m_dbParams.m_forceSave = true;
568  ok = m_dbParams.IsValid("config.xml");
569  }
570  if (!ok)
572 
573  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
574 
576  if (hostname.isEmpty() ||
577  hostname == "my-unique-identifier-goes-here")
578  {
579  QString localhostname = QHostInfo::localHostName();
580  if (localhostname.isEmpty())
581  {
582  LOG(VB_GENERAL, LOG_ALERT,
583  "MCP: Error, could not determine host name." + ENO);
584  }
585 #ifdef Q_OS_ANDROID
586 #define ANDROID_EXCEPTION_CHECK \
587  if (env->ExceptionCheck()) { \
588  env->ExceptionClear(); \
589  exception=true; \
590  }
591 
592  if ((localhostname == "localhost") || localhostname.isEmpty())
593  {
594  hostname = "android";
595  bool exception=false;
596  QAndroidJniEnvironment env;
597  QAndroidJniObject myID = QAndroidJniObject::fromString("android_id");
598  QAndroidJniObject activity = QtAndroid::androidActivity();
600  QAndroidJniObject appctx = activity.callObjectMethod
601  ("getApplicationContext","()Landroid/content/Context;");
603  QAndroidJniObject contentR = appctx.callObjectMethod
604  ("getContentResolver", "()Landroid/content/ContentResolver;");
606  QAndroidJniObject androidId = QAndroidJniObject::callStaticObjectMethod
607  ("android/provider/Settings$Secure","getString",
608  "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
609  contentR.object<jobject>(),
610  myID.object<jstring>());
612  if (exception)
613  LOG(VB_GENERAL, LOG_ALERT,
614  "Java exception looking for android id");
615  else
616  hostname = QString("android-%1").arg(androidId.toString());
617  }
618  else
619  hostname = localhostname;
620 #else
621  hostname = localhostname;
622 #endif
623  LOG(VB_GENERAL, LOG_INFO, "Empty LocalHostName. This is typical.");
624  }
625  else
626  {
627  m_dbParams.m_localEnabled = true;
628  }
629 
630  LOG(VB_GENERAL, LOG_INFO, QString("Using a profile name of: '%1' (Usually the "
631  "same as this host's name.)")
632  .arg(hostname));
634 
635  return ok;
636 }
637 
639  const DatabaseParams &params, bool force)
640 {
641  bool ret = true;
642 
643  // only rewrite file if it has changed
644  if (params != m_dbParams || force)
645  {
647  "LocalHostName", params.m_localHostName);
648 
650  kDefaultDB + "PingHost", params.m_dbHostPing);
651 
652  // If dbHostName is an IPV6 address with scope,
653  // remove the scope. Unescaped % signs are an
654  // xml violation
655  QString dbHostName(params.m_dbHostName);
656  QHostAddress addr;
657  if (addr.setAddress(dbHostName))
658  {
659  addr.setScopeId(QString());
660  dbHostName = addr.toString();
661  }
663  kDefaultDB + "Host", dbHostName);
665  kDefaultDB + "UserName", params.m_dbUserName);
667  kDefaultDB + "Password", params.m_dbPassword);
669  kDefaultDB + "DatabaseName", params.m_dbName);
671  kDefaultDB + "Port", params.m_dbPort);
672 
674  kDefaultWOL + "Enabled", params.m_wolEnabled);
676  kDefaultWOL + "SQLReconnectWaitTime", params.m_wolReconnect);
678  kDefaultWOL + "SQLConnectRetry", params.m_wolRetry);
680  kDefaultWOL + "Command", params.m_wolCommand);
681 
682  // clear out any legacy nodes..
683  m_pConfig->ClearValue(kDefaultMFE + "DBHostName");
684  m_pConfig->ClearValue(kDefaultMFE + "DBUserName");
685  m_pConfig->ClearValue(kDefaultMFE + "DBPassword");
686  m_pConfig->ClearValue(kDefaultMFE + "DBName");
687  m_pConfig->ClearValue(kDefaultMFE + "DBPort");
688  m_pConfig->ClearValue(kDefaultMFE + "DBHostPing");
689 
690  // actually save the file
691  m_pConfig->Save();
692 
693  // Save the new settings:
694  m_dbParams = params;
695  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
696 
697  // If database has changed, force its use:
698  ResetDatabase();
699  }
700  return ret;
701 }
702 
704 {
705  if (d && d->m_loop
706  && d->m_loop->isRunning())
707  d->m_loop->exit();
708 }
709 
710 
712 {
713  bool accepted = false;
714  if (m_gui)
715  {
716  TempMainWindow();
717 
718  // Tell the user what went wrong:
719  if (!error.isEmpty())
721 
722  // ask user for database parameters
723 
724  EnableDBerrors();
726  auto *dbsetting = new DatabaseSettings();
727  auto *ssd = new StandardSettingDialog(mainStack, "databasesettings",
728  dbsetting);
729  if (ssd->Create())
730  {
731  mainStack->AddScreen(ssd);
732  connect(dbsetting, &DatabaseSettings::isClosing,
734  if (!m_loop->isRunning())
735  m_loop->exec();
736  }
737  else
738  delete ssd;
739  SilenceDBerrors();
740  EndTempWindow();
741  accepted = true;
742  }
743  else
744  {
746  QString response;
747  std::this_thread::sleep_for(1s);
748  // give user chance to skip config
749  std::cout << std::endl << error.toLocal8Bit().constData() << std::endl << std::endl;
750  response = getResponse("Would you like to configure the database "
751  "connection now?",
752  "no");
753  if (!response.startsWith('y', Qt::CaseInsensitive))
754  return false;
755 
756  params.m_dbHostName = getResponse("Database host name:",
757  params.m_dbHostName);
758  response = getResponse("Should I test connectivity to this host "
759  "using the ping command?", "yes");
760  params.m_dbHostPing = response.startsWith('y', Qt::CaseInsensitive);
761 
762  params.m_dbPort = intResponse("Database non-default port:",
763  params.m_dbPort);
764  params.m_dbName = getResponse("Database name:",
765  params.m_dbName);
766  params.m_dbUserName = getResponse("Database user name:",
767  params.m_dbUserName);
768  params.m_dbPassword = getResponse("Database password:",
769  params.m_dbPassword);
770 
771  params.m_localHostName = getResponse("Unique identifier for this machine "
772  "(if empty, the local host name "
773  "will be used):",
774  params.m_localHostName);
775  params.m_localEnabled = !params.m_localHostName.isEmpty();
776 
777  response = getResponse("Would you like to use Wake-On-LAN to retry "
778  "database connections?",
779  (params.m_wolEnabled ? "yes" : "no"));
780  params.m_wolEnabled = response.startsWith('y', Qt::CaseInsensitive);
781 
782  if (params.m_wolEnabled)
783  {
784  params.m_wolReconnect =
785  std::chrono::seconds(intResponse("Seconds to wait for "
786  "reconnection:",
787  params.m_wolReconnect.count()));
788  params.m_wolRetry = intResponse("Number of times to retry:",
789  params.m_wolRetry);
790  params.m_wolCommand = getResponse("Command to use to wake server or server MAC address:",
791  params.m_wolCommand);
792  }
793 
794  accepted = m_parent->SaveDatabaseParams(params);
795  }
796  return accepted;
797 }
798 
805 {
806  QString err;
807  QString host;
808 
809  // Jan 20, 2017
810  // Changed to use port check instead of ping
811 
812  int port = 0;
813 
814  // 1 = db awake, 2 = db listening, 3 = db connects,
815  // 4 = backend awake, 5 = backend listening
816  // 9 = all ok, 10 = quit
817 
818  enum startupStates {
819  st_start = 0,
820  st_dbAwake = 1,
821  st_dbStarted = 2,
822  st_dbConnects = 3,
823  st_beWOL = 4,
824  st_beAwake = 5,
825  st_success = 6
826  } startupState = st_start;
827 
828  static const std::array<const QString,7> kGuiStatuses
829  {"start","dbAwake","dbStarted","dbConnects","beWOL","beAwake",
830  "success" };
831 
832  auto secondsStartupScreenDelay = gCoreContext->GetDurSetting<std::chrono::seconds>("StartupScreenDelay",2s);
833  auto msStartupScreenDelay = std::chrono::duration_cast<std::chrono::milliseconds>(secondsStartupScreenDelay);
834  do
835  {
836  QElapsedTimer timer;
837  timer.start();
838  if (m_dbParams.m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
839  host = m_dbHostCp;
840  else
841  host = m_dbParams.m_dbHostName;
842  port = m_dbParams.m_dbPort;
843  if (port == 0)
844  port = 3306;
845  std::chrono::seconds wakeupTime = 3s;
846  int attempts = 11;
847  if (m_dbParams.m_wolEnabled) {
848  wakeupTime = m_dbParams.m_wolReconnect;
849  attempts = m_dbParams.m_wolRetry + 1;
850  startupState = st_start;
851  }
852  else
853  startupState = st_dbAwake;
854  if (attempts < 6)
855  attempts = 6;
856  if (!prompt)
857  attempts=1;
858  if (wakeupTime < 5s)
859  wakeupTime = 5s;
860 
861  std::chrono::seconds progressTotal = wakeupTime * attempts;
862 
864  m_guiStartup->setTotal(progressTotal);
865 
866  QString beWOLCmd = QString();
867  QString backendIP = QString();
868  int backendPort = 0;
869  QString masterserver;
870 
871  for (int attempt = 0;
872  attempt < attempts && startupState != st_success;
873  ++attempt)
874  {
875  // The first time do everything with minimum timeout and
876  // no GUI, for the normal case where all is OK
877  // After that show the GUI (if this is a GUI program)
878 
879  LOG(VB_GENERAL, LOG_INFO,
880  QString("Start up testing connections. DB %1, BE %2, attempt %3, status %4, Delay: %5")
881  .arg(host, backendIP, QString::number(attempt),
882  kGuiStatuses[startupState],
883  QString::number(msStartupScreenDelay.count())) );
884 
885  std::chrono::seconds useTimeout = wakeupTime;
886  if (attempt == 0)
887  useTimeout=1s;
888 
889  if (m_gui && !m_guiStartup)
890  {
891  if (msStartupScreenDelay==0ms || timer.hasExpired(msStartupScreenDelay.count()))
892  {
893  ShowGuiStartup();
894  if (m_guiStartup)
895  m_guiStartup->setTotal(progressTotal);
896  }
897  }
899  {
900  if (attempt > 0)
901  m_guiStartup->setStatusState(kGuiStatuses[startupState]);
902  m_guiStartup->setMessageState("empty");
903  processEvents();
904  }
905  switch (startupState) {
906  case st_start:
908  {
909  if (attempt > 0)
911  if (!checkPort(host, port, useTimeout))
912  break;
913  }
914  startupState = st_dbAwake;
915  [[clang::fallthrough]];
916  case st_dbAwake:
917  if (!checkPort(host, port, useTimeout))
918  break;
919  startupState = st_dbStarted;
920  [[clang::fallthrough]];
921  case st_dbStarted:
922  // If the database is connecting with link-local
923  // address, it may have changed
924  if (m_dbParams.m_dbHostName != host)
925  {
926  m_dbParams.m_dbHostName = host;
927  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
928  }
929  EnableDBerrors();
930  ResetDatabase();
932  {
933  for (std::chrono::seconds temp = 0s; temp < useTimeout * 2 ; temp++)
934  {
935  processEvents();
936  std::this_thread::sleep_for(500ms);
937  }
938  break;
939  }
940  startupState = st_dbConnects;
941  [[clang::fallthrough]];
942  case st_dbConnects:
943  if (m_needsBackend)
944  {
945  beWOLCmd = gCoreContext->GetSetting("WOLbackendCommand", "");
946  if (!beWOLCmd.isEmpty())
947  {
948  wakeupTime += gCoreContext->GetDurSetting<std::chrono::seconds>
949  ("WOLbackendReconnectWaitTime", 0s);
950  attempts += gCoreContext->GetNumSetting
951  ("WOLbackendConnectRetry", 0);
952  useTimeout = wakeupTime;
953  if (m_gui && !m_guiStartup && attempt == 0)
954  useTimeout=1s;
955  progressTotal = wakeupTime * attempts;
957  m_guiStartup->setTotal(progressTotal);
958  startupState = st_beWOL;
959  }
960  }
961  else {
962  startupState = st_success;
963  break;
964  }
965  masterserver = gCoreContext->GetSetting
966  ("MasterServerName");
967  backendIP = gCoreContext->GetSettingOnHost
968  ("BackendServerAddr", masterserver);
969  backendPort = MythCoreContext::GetMasterServerPort();
970  [[clang::fallthrough]];
971  case st_beWOL:
972  if (!beWOLCmd.isEmpty()) {
973  if (attempt > 0)
974  MythWakeup(beWOLCmd);
975  if (!checkPort(backendIP, backendPort, useTimeout))
976  break;
977  }
978  startupState = st_beAwake;
979  [[clang::fallthrough]];
980  case st_beAwake:
981  if (!checkPort(backendIP, backendPort, useTimeout))
982  break;
983  startupState = st_success;
984  [[clang::fallthrough]];
985  case st_success:
986  // Quiet compiler warning.
987  break;
988  }
989  if (m_guiStartup)
990  {
991  if (m_guiStartup->m_Exit
994  || m_guiStartup->m_Retry)
995  break;
996  }
997  processEvents();
998  }
999  if (startupState == st_success)
1000  break;
1001 
1002  QString stateMsg = kGuiStatuses[startupState];
1003  stateMsg.append("Fail");
1004  LOG(VB_GENERAL, LOG_INFO,
1005  QString("Start up failure. host %1, status %2")
1006  .arg(host, stateMsg));
1007 
1008  if (m_gui && !m_guiStartup)
1009  {
1010  ShowGuiStartup();
1011  if (m_guiStartup)
1012  m_guiStartup->setTotal(progressTotal);
1013  }
1014 
1015  if (m_guiStartup
1016  && !m_guiStartup->m_Exit
1017  && !m_guiStartup->m_Setup
1018  && !m_guiStartup->m_Search
1019  && !m_guiStartup->m_Retry)
1020  {
1022  m_guiStartup->setStatusState(stateMsg);
1023  m_guiStartup->setMessageState("makeselection");
1024  m_loop->exec();
1025  }
1026  }
1027  while (m_guiStartup && m_guiStartup->m_Retry);
1028 
1029  if (startupState < st_dbAwake)
1030  {
1031  LOG(VB_GENERAL, LOG_WARNING, QString("Pinging to %1 failed, database will be unavailable").arg(host));
1032  SilenceDBerrors();
1033  err = QObject::tr(
1034  "Cannot find (ping) database host %1 on the network",
1035  "Backend Setup");
1036  return err.arg(host);
1037  }
1038 
1039  if (startupState < st_dbConnects)
1040  {
1041  SilenceDBerrors();
1042  return QObject::tr("Cannot login to database", "Backend Setup");
1043  }
1044 
1045  if (startupState < st_success)
1046  {
1047  return QObject::tr("Cannot connect to backend", "Backend Setup");
1048  }
1049 
1050  // Current DB connection may have been silenced (invalid):
1051  EnableDBerrors();
1052  ResetDatabase();
1053 
1054  return {};
1055 }
1056 
1057 // Show the Gui Startup window.
1058 // This is called if there is a delay in startup for any reason
1059 // such as the database being unavailable
1061 {
1062  if (!m_gui)
1063  return;
1064  TempMainWindow(false);
1065  MythMainWindow *mainWindow = GetMythMainWindow();
1066  MythScreenStack *mainStack = mainWindow->GetMainStack();
1067  if (mainStack) {
1068  if (!m_guiStartup) {
1069  m_guiStartup = new GUIStartup(mainStack,m_loop);
1070  if (!m_guiStartup->Create()) {
1071  delete m_guiStartup;
1072  m_guiStartup = nullptr;
1073  }
1074  if (m_guiStartup) {
1075  mainStack->AddScreen(m_guiStartup, false);
1076  processEvents();
1077  }
1078  }
1079  }
1080 }
1081 
1091 {
1092  // This silences any DB errors from Get*Setting(),
1093  // (which is the vast majority of them)
1094  gCoreContext->GetDB()->SetSuppressDBMessages(true);
1095 
1096  // Save the configured hostname, so that we can
1097  // still display it in the DatabaseSettings screens
1098  if (!m_dbParams.m_dbHostName.isEmpty())
1100 
1101  m_dbParams.m_dbHostName.clear();
1102  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
1103 }
1104 
1106 {
1107  // Restore (possibly) blanked hostname
1108  if (m_dbParams.m_dbHostName.isNull() && !m_dbHostCp.isEmpty())
1109  {
1111  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
1112  }
1113 
1114  gCoreContext->GetDB()->SetSuppressDBMessages(false);
1115 }
1116 
1117 
1130 {
1132  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
1134 }
1135 
1140 {
1141  TempMainWindow();
1142 
1143  // Tell the user what went wrong:
1144  if (!error.isEmpty())
1145  {
1146  LOG(VB_GENERAL, LOG_ERR, QString("Error: %1").arg(error));
1147  ShowOkPopup(error);
1148  }
1149 
1150  LOG(VB_GENERAL, LOG_INFO, "Putting up the UPnP backend chooser");
1151 
1154 
1155  EndTempWindow();
1156 
1157  return (int)ret;
1158 }
1159 
1166 int MythContextPrivate::UPnPautoconf(const std::chrono::milliseconds milliSeconds)
1167 {
1168  auto seconds = duration_cast<std::chrono::seconds>(milliSeconds);
1169  LOG(VB_GENERAL, LOG_INFO, QString("UPNP Search %1 secs")
1170  .arg(seconds.count()));
1171 
1173 
1174  // Search for a total of 'milliSeconds' ms, sending new search packet
1175  // about every 250 ms until less than one second remains.
1176  MythTimer totalTime; totalTime.start();
1177  MythTimer searchTime; searchTime.start();
1178  while (totalTime.elapsed() < milliSeconds)
1179  {
1180  usleep(25000);
1181  auto ttl = milliSeconds - totalTime.elapsed();
1182  if ((searchTime.elapsed() > 249ms) && (ttl > 1s))
1183  {
1184  auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1185  LOG(VB_GENERAL, LOG_INFO, QString("UPNP Search %1 secs")
1186  .arg(ttlSeconds.count()));
1187  SSDP::Instance()->PerformSearch(kBackendURI, ttlSeconds);
1188  searchTime.start();
1189  }
1190  }
1191 
1193 
1194  if (!backends)
1195  {
1196  LOG(VB_GENERAL, LOG_INFO, "No UPnP backends found");
1197  return 0;
1198  }
1199 
1200  int count = backends->Count();
1201  if (count)
1202  {
1203  LOG(VB_GENERAL, LOG_INFO,
1204  QString("Found %1 UPnP backends").arg(count));
1205  }
1206  else
1207  {
1208  LOG(VB_GENERAL, LOG_ERR,
1209  "No UPnP backends found, but SSDP::Find() not NULL");
1210  }
1211 
1212  if (count != 1)
1213  {
1214  backends->DecrRef();
1215  return count;
1216  }
1217 
1218  // Get this backend's location:
1219  DeviceLocation *BE = backends->GetFirst();
1220  backends->DecrRef();
1221  backends = nullptr;
1222 
1223  // We don't actually know the backend's access PIN, so this will
1224  // only work for ones that have PIN access disabled (i.e. 0000)
1225  int ret = (UPnPconnect(BE, QString())) ? 1 : -1;
1226 
1227  BE->DecrRef();
1228 
1229  return ret;
1230 }
1231 
1238 {
1239  static const QString loc = "DefaultUPnP() - ";
1240  QString pin = m_pConfig->GetValue(kDefaultPIN, "");
1241  QString usn = m_pConfig->GetValue(kDefaultUSN, "");
1242 
1243  if (usn.isEmpty())
1244  {
1245  LOG(VB_UPNP, LOG_INFO, loc + "No default UPnP backend");
1246  return false;
1247  }
1248 
1249  LOG(VB_UPNP, LOG_INFO, loc + QString("config.xml has default PIN '%1' and host USN: %2")
1250  .arg(pin, usn));
1251 
1252  // ----------------------------------------------------------------------
1253 
1254  std::chrono::milliseconds timeout_ms { 2s };
1255  auto timeout_s = duration_cast<std::chrono::seconds>(timeout_ms);
1256  LOG(VB_GENERAL, LOG_INFO, loc + QString("UPNP Search up to %1 secs")
1257  .arg(timeout_s.count()));
1258  SSDP::Instance()->PerformSearch(kBackendURI, timeout_s);
1259 
1260  // ----------------------------------------------------------------------
1261  // We need to give the server time to respond...
1262  // ----------------------------------------------------------------------
1263 
1264  DeviceLocation* devicelocation = nullptr;
1265  MythTimer totalTime;
1266  MythTimer searchTime;
1267  totalTime.start();
1268  searchTime.start();
1269  while (totalTime.elapsed() < timeout_ms)
1270  {
1271  devicelocation = SSDP::Find(kBackendURI, usn);
1272  if (devicelocation)
1273  break;
1274 
1275  usleep(25000);
1276 
1277  auto ttl = timeout_ms - totalTime.elapsed();
1278  if ((searchTime.elapsed() > 249ms) && (ttl > 1s))
1279  {
1280  auto ttlSeconds = duration_cast<std::chrono::seconds>(ttl);
1281  LOG(VB_GENERAL, LOG_INFO, loc + QString("UPNP Search up to %1 secs")
1282  .arg(ttlSeconds.count()));
1283  SSDP::Instance()->PerformSearch(kBackendURI, ttlSeconds);
1284  searchTime.start();
1285  }
1286  }
1287 
1288  // ----------------------------------------------------------------------
1289 
1290  if (!devicelocation)
1291  {
1292  Error = "Cannot find default UPnP backend";
1293  return false;
1294  }
1295 
1296  if (UPnPconnect(devicelocation, pin))
1297  {
1298  devicelocation->DecrRef();
1299  return true;
1300  }
1301 
1302  devicelocation->DecrRef();
1303  Error = "Cannot connect to default backend via UPnP. Wrong saved PIN?";
1304  return false;
1305 }
1306 
1311  const QString &PIN)
1312 {
1313  QString error;
1314  QString loc = "UPnPconnect() - ";
1315  QString URL = backend->m_sLocation;
1316  MythXMLClient client(URL);
1317 
1318  LOG(VB_UPNP, LOG_INFO, loc + QString("Trying host at %1").arg(URL));
1319  switch (client.GetConnectionInfo(PIN, &m_dbParams, error))
1320  {
1321  case UPnPResult_Success:
1322  gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);
1323  LOG(VB_UPNP, LOG_INFO, loc +
1324  "Got database hostname: " + m_dbParams.m_dbHostName);
1325  return true;
1326 
1328  // The stored PIN is probably not correct.
1329  // We could prompt for the PIN and try again, but that needs a UI.
1330  // Easier to fail for now, and put up the full UI selector later
1331  LOG(VB_UPNP, LOG_ERR, loc + "Wrong PIN?");
1332  return false;
1333 
1334  default:
1335  LOG(VB_UPNP, LOG_ERR, loc + error);
1336  break;
1337  }
1338 
1339  // This backend may have a local DB with the default user/pass/DBname.
1340  // For whatever reason, we have failed to get anything back via UPnP,
1341  // so we might as well try the database directly as a last resort.
1342  QUrl theURL(URL);
1343  URL = theURL.host();
1344  if (URL.isEmpty())
1345  return false;
1346 
1347  LOG(VB_UPNP, LOG_INFO, "Trying default DB credentials at " + URL);
1348  m_dbParams.m_dbHostName = URL;
1349 
1350  return true;
1351 }
1352 
1354 {
1355  if (e->type() == MythEvent::MythEventMessage)
1356  {
1357  if (m_disableeventpopup)
1358  return true;
1359 
1361  {
1363  }
1364 
1365  auto *me = dynamic_cast<MythEvent*>(e);
1366  if (me == nullptr)
1367  return true;
1368 
1369  if (me->Message() == "VERSION_MISMATCH" && (1 == me->ExtraDataCount()))
1370  ShowVersionMismatchPopup(me->ExtraData(0).toUInt());
1371  else if (me->Message() == "CONNECTION_FAILURE")
1373  else if (me->Message() == "PERSISTENT_CONNECTION_FAILURE")
1375  else if (me->Message() == "CONNECTION_RESTABLISHED")
1377  return true;
1378  }
1379 
1380  return QObject::event(e);
1381 }
1382 
1384 {
1385  QDateTime now = MythDate::current();
1386 
1387  if (!GetNotificationCenter() || !m_ui || !m_ui->IsScreenSetup())
1388  return;
1389 
1390  if (m_lastCheck.isValid() && now < m_lastCheck)
1391  return;
1392 
1393  // When WOL is disallowed, standy mode,
1394  // we should not show connection failures.
1395  if (!gCoreContext->IsWOLAllowed())
1396  return;
1397 
1398  m_lastCheck = now.addMSecs(5000); // don't refresh notification more than every 5s
1399 
1400  QString description = (persistent) ?
1401  QObject::tr(
1402  "The connection to the master backend "
1403  "server has gone away for some reason. "
1404  "Is it running?") :
1405  QObject::tr(
1406  "Could not connect to the master backend server. Is "
1407  "it running? Is the IP address set for it in "
1408  "mythtv-setup correct?");
1409 
1410  QString message = QObject::tr("Could not connect to master backend");
1411  MythErrorNotification n(message, sLocation, description);
1412  n.SetId(m_registration);
1413  n.SetParent(this);
1415 }
1416 
1418 {
1419  if (!GetNotificationCenter())
1420  return;
1421 
1422  if (!m_lastCheck.isValid())
1423  return;
1424 
1425  MythCheckNotification n(QObject::tr("Backend is online"), sLocation);
1426  n.SetId(m_registration);
1427  n.SetParent(this);
1428  n.SetDuration(5s);
1430  m_lastCheck = QDateTime();
1431 }
1432 
1434 {
1435  if (m_mbeVersionPopup)
1436  return;
1437 
1438  QString message =
1439  QObject::tr(
1440  "The server uses network protocol version %1, "
1441  "but this client only understands version %2. "
1442  "Make sure you are running compatible versions of "
1443  "the backend and frontend.")
1444  .arg(remote_version).arg(MYTH_PROTO_VERSION);
1445 
1446  if (HasMythMainWindow() && m_ui && m_ui->IsScreenSetup())
1447  {
1450  }
1451  else
1452  {
1453  LOG(VB_GENERAL, LOG_ERR, LOC + message);
1454  qApp->exit(GENERIC_EXIT_SOCKET_ERROR);
1455  }
1456 }
1457 
1458 // Process Events while waiting for connection
1459 // return true if progress is 100%
1461 {
1462 // bool ret = false;
1463 // if (m_guiStartup)
1464 // ret = m_guiStartup->updateProgress();
1465  qApp->processEvents(QEventLoop::AllEvents, 250);
1466  qApp->processEvents(QEventLoop::AllEvents, 250);
1467 // return ret;
1468 }
1469 
1470 // cache some settings in cache/contextcache.xml
1471 // only call this if the database is available.
1472 
1473 const std::vector<QString> MythContextPrivate::kSettingsToSave
1474 { "Theme", "Language", "Country", "GuiHeight",
1475  "GuiOffsetX", "GuiOffsetY", "GuiWidth", "RunFrontendInWindow",
1476  "AlwaysOnTop", "HideMouseCursor", "ThemePainter", "libCECEnabled",
1477  "StartupScreenDelay" };
1478 
1479 
1481 {
1482  if (!m_gui)
1483  return true;
1484  QString cacheDirName = GetConfDir() + "/cache/";
1485  QDir dir(cacheDirName);
1486  dir.mkpath(cacheDirName);
1487  XmlConfiguration config = XmlConfiguration("cache/contextcache.xml");
1488  for (const auto & setting : kSettingsToSave)
1489  {
1490  QString cacheValue = config.GetValue("Settings/"+setting,QString());
1492  QString value = gCoreContext->GetSetting(setting,QString());
1493  if (value != cacheValue)
1494  {
1495  config.SetValue("Settings/"+setting,value);
1496  m_settingsCacheDirty = true;
1497  }
1498  }
1500  return config.Save();
1501 }
1502 
1504 {
1505  if (!m_gui)
1506  return;
1507  XmlConfiguration config = XmlConfiguration("cache/contextcache.xml");
1508  for (const auto & setting : kSettingsToSave)
1509  {
1510  if (!gCoreContext->GetSetting(setting,QString()).isEmpty())
1511  continue;
1512  QString value = config.GetValue("Settings/"+setting,QString());
1513  if (!value.isEmpty())
1514  gCoreContext->OverrideSettingForSession(setting, value);
1515  }
1516  // Prevent power off TV after temporary window
1517  gCoreContext->OverrideSettingForSession("PowerOffTVAllowed", nullptr);
1518 
1519  MythTranslation::load("mythfrontend");
1520 }
1521 
1523 {
1524  QString language = gCoreContext->GetSetting("Language",QString());
1525  for (const auto & setting : kSettingsToSave)
1527  // Restore power off TV setting
1528  gCoreContext->ClearOverrideSettingForSession("PowerOffTVAllowed");
1529 
1530  if (language != gCoreContext->GetSetting("Language",QString()))
1531  MythTranslation::load("mythfrontend");
1532 }
1533 
1534 
1536 {
1537  d->m_mbeVersionPopup = nullptr;
1538  qApp->exit(GENERIC_EXIT_SOCKET_ERROR);
1539 }
1540 
1541 MythContext::MythContext(QString binversion, bool needsBackend)
1542  : m_appBinaryVersion(std::move(binversion))
1543 {
1544 #ifdef _WIN32
1545  static bool WSAStarted = false;
1546  if (!WSAStarted) {
1547  WSADATA wsadata;
1548  int res = WSAStartup(MAKEWORD(2, 0), &wsadata);
1549  LOG(VB_SOCKET, LOG_INFO,
1550  QString("WSAStartup returned %1").arg(res));
1551  }
1552 #endif
1553 
1554  d = new MythContextPrivate(this);
1555  d->m_needsBackend = needsBackend;
1556 
1558 
1559  if (!gCoreContext || !gCoreContext->Init())
1560  {
1561  LOG(VB_GENERAL, LOG_EMERG, LOC + "Unable to allocate MythCoreContext");
1562  qApp->exit(GENERIC_EXIT_NO_MYTHCONTEXT);
1563  }
1564 }
1565 
1566 bool MythContext::Init(const bool gui,
1567  const bool promptForBackend,
1568  const bool disableAutoDiscovery,
1569  const bool ignoreDB)
1570 {
1571  if (!d)
1572  {
1573  LOG(VB_GENERAL, LOG_EMERG, LOC + "Init() Out-of-memory");
1574  return false;
1575  }
1576 
1577  qRegisterMetaType<std::chrono::seconds>("std::chrono::seconds");
1578  qRegisterMetaType<std::chrono::milliseconds>("std::chrono::milliseconds");
1579  qRegisterMetaType<std::chrono::microseconds>("std::chrono::microseconds");
1580 
1581  SetDisableEventPopup(true);
1582 
1584  {
1585  LOG(VB_GENERAL, LOG_EMERG,
1586  QString("Application binary version (%1) does not "
1587  "match libraries (%2)")
1589 
1590  QString warning = QObject::tr(
1591  "This application is not compatible "
1592  "with the installed MythTV libraries.");
1593  if (gui)
1594  {
1595  d->TempMainWindow(false);
1596  ShowOkPopup(warning);
1597  }
1598  LOG(VB_GENERAL, LOG_WARNING, warning);
1599 
1600  return false;
1601  }
1602 
1603 #ifdef _WIN32
1604  // HOME environment variable might not be defined
1605  // some libraries will fail without it
1606  QString home = getenv("HOME");
1607  if (home.isEmpty())
1608  {
1609  home = getenv("LOCALAPPDATA"); // Vista
1610  if (home.isEmpty())
1611  home = getenv("APPDATA"); // XP
1612  if (home.isEmpty())
1613  home = QString("."); // getenv("TEMP")?
1614 
1615  _putenv(QString("HOME=%1").arg(home).toLocal8Bit().constData());
1616  }
1617 #endif
1618 
1619  // If HOME isn't defined, we won't be able to use default confdir of
1620  // $HOME/.mythtv nor can we rely on a MYTHCONFDIR that references $HOME
1621  QString homedir = QDir::homePath();
1622  QString confdir = qEnvironmentVariable("MYTHCONFDIR");
1623  if ((homedir.isEmpty() || homedir == "/") &&
1624  (confdir.isEmpty() || confdir.contains("$HOME")))
1625  {
1626  QString warning = "Cannot locate your home directory."
1627  " Please set the environment variable HOME";
1628  if (gui)
1629  {
1630  d->TempMainWindow(false);
1631  ShowOkPopup(warning);
1632  }
1633  LOG(VB_GENERAL, LOG_WARNING, warning);
1634 
1635  return false;
1636  }
1637 
1638  if (!d->Init(gui, promptForBackend, disableAutoDiscovery, ignoreDB))
1639  {
1640  return false;
1641  }
1642 
1643  SetDisableEventPopup(false);
1645  if (d->m_settingsCacheDirty)
1646  {
1647 #ifndef Q_OS_ANDROID
1649 #endif
1650  d->m_settingsCacheDirty = false;
1651  }
1654 
1655  return true;
1656 }
1657 
1659 {
1660  gCoreContext->InitPower(false /*destroy*/);
1661  if (MThreadPool::globalInstance()->activeThreadCount())
1662  LOG(VB_GENERAL, LOG_INFO, "Waiting for threads to exit.");
1663 
1665  SSDP::Shutdown();
1667 
1668  LOG(VB_GENERAL, LOG_INFO, "Exiting");
1669 
1670  logStop();
1671 
1672  delete gCoreContext;
1673  gCoreContext = nullptr;
1674 
1675  delete d;
1676 }
1677 
1679 {
1680  d->m_disableeventpopup = check;
1681 }
1682 
1684 {
1685  return d->m_dbParams;
1686 }
1687 
1689 {
1690  return d->SaveDatabaseParams(params, false);
1691 }
1692 
1694 {
1695  return d->saveSettingsCache();
1696 }
1697 
1698 /* vim: set expandtab tabstop=4 shiftwidth=4: */
Configuration::GetDuration
std::enable_if< std::chrono::__is_duration< T >::value, T >::type GetDuration(const QString &sSetting, T defaultval=T::zero())
Definition: configuration.h:41
MythContextPrivate::ShowConnectionFailurePopup
void ShowConnectionFailurePopup(bool persistent)
Definition: mythcontext.cpp:1383
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:315
MythTimer::elapsed
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
Definition: mythtimer.cpp:91
mythevent.h
XmlConfiguration::Save
bool Save(void) override
Definition: configuration.cpp:88
MythContext::MythContext
MythContext(QString binversion, bool needsBackend=false)
Definition: mythcontext.cpp:1541
Configuration::SetDuration
std::enable_if< std::chrono::__is_duration< T >::value, void >::type SetDuration(const QString &sSetting, T value)
Definition: configuration.h:45
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:79
ENO
#define ENO
This can be appended to the LOG args with "+".
Definition: mythlogging.h:72
PortChecker
Small class to handle TCP port checking and finding link-local context.
Definition: portchecker.h:44
GUIStartup::Create
bool Create(void) override
Definition: guistartup.cpp:70
DatabaseParams::m_dbHostName
QString m_dbHostName
database server
Definition: mythdbparams.h:22
MediaMonitor::ejectOpticalDisc
static void ejectOpticalDisc(void)
Eject a disk, unmount a drive, open a tray.
Definition: mythmediamonitor.cpp:980
MythContextSlotHandler::VersionMismatchPopupClosed
void VersionMismatchPopupClosed(void)
Definition: mythcontext.cpp:1535
MythPluginManager
Definition: mythplugin.h:62
dbutil.h
MythMainWindow::Init
void Init(bool MayReInit=true)
Definition: mythmainwindow.cpp:638
error
static void error(const char *str,...)
Definition: vbi.cpp:36
ReferenceCounter::DecrRef
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
Definition: referencecounter.cpp:125
ShowNotificationError
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
Definition: mythnotificationcenter.cpp:1427
MythContextSlotHandler::MythContextPrivate
friend class MythContextPrivate
Definition: mythcontext.h:16
SSDP::PerformSearch
void PerformSearch(const QString &sST, std::chrono::seconds timeout=2s)
Definition: ssdp.cpp:202
MythContextPrivate::event
bool event(QEvent *) override
Definition: mythcontext.cpp:1353
mythdb.h
MythCoreContext::SendReceiveStringList
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
Definition: mythcorecontext.cpp:1375
MythContextPrivate::kSettingsToSave
static const std::vector< QString > kSettingsToSave
Definition: mythcontext.cpp:139
MythContextPrivate::UPnPautoconf
int UPnPautoconf(std::chrono::milliseconds milliSeconds=2s)
If there is only a single UPnP backend, use it.
Definition: mythcontext.cpp:1166
MythTimer
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
MythCheckNotification
Definition: mythnotification.h:212
MythContextPrivate::DefaultUPnP
bool DefaultUPnP(QString &Error)
Get the default backend from config.xml, use UPnP to find it.
Definition: mythcontext.cpp:1237
MythContext::GetDatabaseParams
DatabaseParams GetDatabaseParams(void)
Definition: mythcontext.cpp:1683
DatabaseParams::m_forceSave
bool m_forceSave
set to true to force a save of the settings file
Definition: mythdbparams.h:40
MythNotification::SetDuration
void SetDuration(std::chrono::seconds Duration)
Contains a duration during which the notification will be displayed for. The duration is informative ...
Definition: mythnotification.cpp:136
MythContextPrivate::m_mbeVersionPopup
MythConfirmationDialog * m_mbeVersionPopup
Definition: mythcontext.cpp:135
MythNotificationCenter::Register
int Register(void *from)
An application can register in which case it will be assigned a reusable screen, which can be modifie...
Definition: mythnotificationcenter.cpp:1369
MythCoreContext::GetDBManager
MDBManager * GetDBManager(void)
Definition: mythcorecontext.cpp:869
MythUIHelper::IsScreenSetup
bool IsScreenSetup() const
Definition: mythuihelper.cpp:98
MythPluginManager::run_plugin
bool run_plugin(const QString &plugname)
Definition: mythplugin.cpp:159
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
dbsettings.h
mythplugin.h
MythCoreContext::InitLocale
void InitLocale(void)
Definition: mythcorecontext.cpp:1843
MythContext
Startup context for MythTV.
Definition: mythcontext.h:43
XmlConfiguration::GetValue
int GetValue(const QString &sSetting, int Default) override
Definition: configuration.cpp:210
MythMainWindow::getMainWindow
static MythMainWindow * getMainWindow(bool UseDB=true)
Return the existing main window, or create one.
Definition: mythmainwindow.cpp:78
MythXMLClient
Definition: mythxmlclient.h:31
MythContextPrivate::saveSettingsCache
bool saveSettingsCache(void)
Definition: mythcontext.cpp:1480
MythCoreContext::OverrideSettingForSession
void OverrideSettingForSession(const QString &key, const QString &value)
Definition: mythcorecontext.cpp:1341
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MythContext::SetDisableEventPopup
void SetDisableEventPopup(bool check)
Definition: mythcontext.cpp:1678
MythContextPrivate::TestDBconnection
QString TestDBconnection(bool prompt=true)
Some quick sanity checks before opening a database connection.
Definition: mythcontext.cpp:804
mythxmlclient.h
kDefaultWOL
const QString kDefaultWOL
Definition: backendselect.h:22
mythdialogbox.h
MythScreenStack
Definition: mythscreenstack.h:16
SSDP::Find
static SSDPCacheEntries * Find(const QString &sURI)
Definition: ssdp.h:129
mythmediamonitor.h
MythContextPrivate::m_loop
QEventLoop * m_loop
Definition: mythcontext.cpp:130
MythContextPrivate::m_parent
MythContext * m_parent
Definition: mythcontext.cpp:113
confdir
static QString confdir
Definition: mythdirs.cpp:20
MythTimer::start
void start(void)
starts measuring elapsed time.
Definition: mythtimer.cpp:47
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythContextPrivate::~MythContextPrivate
~MythContextPrivate() override
Definition: mythcontext.cpp:248
MythContextPrivate::UPnPconnect
bool UPnPconnect(const DeviceLocation *backend, const QString &PIN)
Query a backend via UPnP for its database connection parameters.
Definition: mythcontext.cpp:1310
DatabaseSettings::isClosing
void isClosing(void)
MythContextPrivate::ShowVersionMismatchPopup
void ShowVersionMismatchPopup(uint remote_version)
Definition: mythcontext.cpp:1433
MythContextPrivate::checkPort
bool checkPort(QString &host, int port, std::chrono::seconds timeLimit) const
Check if a port is open and sort out the link-local scope.
Definition: mythcontext.cpp:322
mythdirs.h
force
bool force
Definition: mythcommflag.cpp:70
MythContextPrivate::ShowGuiStartup
void ShowGuiStartup(void)
Definition: mythcontext.cpp:1060
myth_system
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
Definition: mythsystemlegacy.cpp:506
DeviceLocation
Definition: upnpdevice.h:210
MythContextPrivate::m_disableeventpopup
bool m_disableeventpopup
Definition: mythcontext.cpp:125
HasMythMainWindow
bool HasMythMainWindow(void)
Definition: mythmainwindow.cpp:107
MythCoreContext::InitPower
void InitPower(bool Create=true)
Definition: mythcorecontext.cpp:1830
GUIStartup::m_Search
bool m_Search
Definition: guistartup.h:60
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
DatabaseParams::m_wolReconnect
std::chrono::seconds m_wolReconnect
seconds to wait for reconnect
Definition: mythdbparams.h:35
MythContextPrivate::EnableDBerrors
void EnableDBerrors(void)
Definition: mythcontext.cpp:1105
XmlConfiguration
Definition: configuration.h:60
SSDP::Shutdown
static void Shutdown()
Definition: ssdp.cpp:65
langsettings.h
MythContext::m_appBinaryVersion
QString m_appBinaryVersion
Definition: mythcontext.h:63
InitializeMythDirs
void InitializeMythDirs(void)
Definition: mythdirs.cpp:30
DatabaseSettings
Definition: dbsettings.h:10
exec_program_tv_cb
static void exec_program_tv_cb(const QString &cmd)
Definition: mythcontext.cpp:147
mythversion.h
mythsystemlegacy.h
eject_cb
static void eject_cb(void)
Definition: mythcontext.cpp:235
MythCoreContext::ClearOverrideSettingForSession
void ClearOverrideSettingForSession(const QString &key)
Definition: mythcorecontext.cpp:1347
SSDP::Instance
static SSDP * Instance()
Definition: ssdp.cpp:55
Configuration::ClearValue
virtual void ClearValue(const QString &sSetting)=0
MythContext::d
MythContextPrivate * d
Definition: mythcontext.h:62
StandardSettingDialog
Definition: standardsettings.h:468
DatabaseParams::m_dbPort
int m_dbPort
database port
Definition: mythdbparams.h:24
kDefaultDB
const QString kDefaultDB
Definition: backendselect.h:21
mythdate.h
Configuration::SetValue
virtual void SetValue(const QString &sSetting, int value)=0
MDBManager::CloseDatabases
void CloseDatabases(void)
Definition: mythdbcon.cpp:473
upnp.h
guistartup.h
mythlogging.h
MythContextPrivate::m_settingsCacheDirty
bool m_settingsCacheDirty
Definition: mythcontext.cpp:132
MythContextPrivate::OnCloseDialog
void OnCloseDialog()
MythCoreContext::Init
bool Init(void)
Definition: mythcorecontext.cpp:224
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
XmlConfiguration::SetValue
void SetValue(const QString &sSetting, int value) override
Definition: configuration.cpp:250
DatabaseParams::m_dbHostPing
bool m_dbHostPing
Can we test connectivity using ping?
Definition: mythdbparams.h:23
remotefile.h
MythContextPrivate::EndTempWindow
void EndTempWindow(void)
Definition: mythcontext.cpp:297
configplugin_cb
static void configplugin_cb(const QString &cmd)
Definition: mythcontext.cpp:208
MThreadPool::waitForDone
void waitForDone(void)
Definition: mthreadpool.cpp:574
MythContextPrivate::m_pConfig
Configuration * m_pConfig
Definition: mythcontext.cpp:123
compat.h
BackendSelection::kCancelConfigure
@ kCancelConfigure
Definition: backendselect.h:44
MythNotification::SetParent
void SetParent(void *Parent)
Contains the parent address. Required if id is set Id provided must match the parent address as provi...
Definition: mythnotification.cpp:98
MythContextPrivate::m_socket
QTcpSocket * m_socket
Definition: mythcontext.cpp:138
MythCoreContext::GetDurSetting
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
Definition: mythcorecontext.h:173
MSqlQuery::testDBConnection
static bool testDBConnection()
Checks DB connection + login (login info via Mythcontext)
Definition: mythdbcon.cpp:871
MythContextPrivate::MythContextPrivate
MythContextPrivate(MythContext *lparent)
Definition: mythcontext.cpp:240
MythContextPrivate::ChooseBackend
int ChooseBackend(const QString &error)
Search for backends via UPnP, put up a UI for the user to choose one.
Definition: mythcontext.cpp:1139
DestroyMythMainWindow
void DestroyMythMainWindow(void)
Definition: mythmainwindow.cpp:112
DeviceLocation::m_sLocation
QString m_sLocation
Definition: upnpdevice.h:236
MythCoreContext::IsFrontend
bool IsFrontend(void) const
is this process a frontend process
Definition: mythcorecontext.cpp:658
BackendSelection::kAcceptConfigure
@ kAcceptConfigure
Definition: backendselect.h:45
MythErrorNotification
Definition: mythnotification.h:198
getResponse
QString getResponse(const QString &query, const QString &def)
In an interactive shell, prompt the user to input a string.
Definition: mythmiscutil.cpp:415
MythCoreContext::GetDB
MythDB * GetDB(void)
Definition: mythcorecontext.cpp:1763
MythWakeup
bool MythWakeup(const QString &wakeUpCommand, uint flags, std::chrono::seconds timeout)
Definition: mythmiscutil.cpp:635
mythtranslation.h
Configuration::GetBoolValue
virtual bool GetBoolValue(const QString &sSetting, bool Default)=0
MythContextPrivate::SaveDatabaseParams
bool SaveDatabaseParams(const DatabaseParams &params, bool force)
Definition: mythcontext.cpp:638
DatabaseParams::m_dbPassword
QString m_dbPassword
DB password.
Definition: mythdbparams.h:26
portchecker.h
sLocation
static const QString sLocation
Definition: mythcontext.cpp:61
DatabaseParams::m_wolRetry
int m_wolRetry
times to retry to reconnect
Definition: mythdbparams.h:36
kBackendURI
const QString kBackendURI
Definition: backendselect.h:20
DatabaseParams::m_dbName
QString m_dbName
database name
Definition: mythdbparams.h:27
MythContextPrivate::PromptForDatabaseParams
bool PromptForDatabaseParams(const QString &error)
Definition: mythcontext.cpp:711
TaskQueue::Shutdown
static void Shutdown()
Definition: taskqueue.cpp:69
SSDPCacheEntries
Definition: ssdpcache.h:35
uint
unsigned int uint
Definition: compat.h:79
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:59
UPnPResult_ActionNotAuthorized
@ UPnPResult_ActionNotAuthorized
Definition: upnp.h:48
MythContextPrivate::m_ui
MythUIHelper * m_ui
Definition: mythcontext.cpp:127
MythContextPrivate::clearSettingsCacheOverride
static void clearSettingsCacheOverride(void)
Definition: mythcontext.cpp:1522
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
logStop
void logStop(void)
Entry point for stopping logging for an application.
Definition: logging.cpp:717
MythContextPrivate::m_registration
int m_registration
Definition: mythcontext.cpp:136
MythContextPrivate::m_masterhostname
QString m_masterhostname
master backend hostname
Definition: mythcontext.cpp:118
exec_program_cb
static void exec_program_cb(const QString &cmd)
Definition: mythcontext.cpp:142
MythUIMenuCallbacks::exec_program
void(* exec_program)(const QString &cmd)
Definition: mythuihelper.h:16
MythCoreContext::SetLocalHostname
void SetLocalHostname(const QString &hostname)
Definition: mythcorecontext.cpp:1736
MythContextSlotHandler::d
MythContextPrivate * d
Definition: mythcontext.h:31
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:34
GUIStartup::setTotal
void setTotal(std::chrono::seconds total)
Definition: guistartup.cpp:131
plugin_cb
static void plugin_cb(const QString &cmd)
Definition: mythcontext.cpp:221
GUIStartup::updateProgress
bool updateProgress(bool finished)
Definition: guistartup.cpp:147
MythPluginManager::config_plugin
bool config_plugin(const QString &plugname)
Definition: mythplugin.cpp:177
mythuihelper.h
MythContextPrivate::SilenceDBerrors
void SilenceDBerrors(void)
Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently.
Definition: mythcontext.cpp:1090
MYTH_BINARY_VERSION
#define MYTH_BINARY_VERSION
Update this whenever the plug-in ABI changes.
Definition: mythversion.h:15
MythContextPrivate::m_sh
MythContextSlotHandler * m_sh
Definition: mythcontext.cpp:128
MythCoreContext::GetMasterServerPort
static int GetMasterServerPort(void)
Returns the Master Backend control port If no master server port has been defined in the database,...
Definition: mythcorecontext.cpp:984
MYTH_PROTO_VERSION
#define MYTH_PROTO_VERSION
Increment this whenever the MythTV network protocol changes.
Definition: mythversion.h:47
PortChecker::checkPort
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.
Definition: portchecker.cpp:73
GUIStartup::m_Retry
bool m_Retry
Definition: guistartup.h:59
mythimage.h
DatabaseParams::LoadDefaults
void LoadDefaults(void)
Load sensible connection defaults.
Definition: mythdbparams.cpp:9
GUIStartup::setMessageState
bool setMessageState(const QString &name)
Definition: guistartup.cpp:120
MythContextPrivate::FindDatabase
bool FindDatabase(bool prompt, bool noAutodetect)
Get database connection settings and test connectivity.
Definition: mythcontext.cpp:407
GUIStartup::setStatusState
bool setStatusState(const QString &name)
Definition: guistartup.cpp:110
MythCoreContext
This class contains the runtime context for MythTV.
Definition: mythcorecontext.h:65
mythmiscutil.h
MythConfirmationDialog
Dialog asking for user confirmation. Ok and optional Cancel button.
Definition: mythdialogbox.h:272
MythContextPrivate::LoadDatabaseSettings
bool LoadDatabaseSettings(void)
Load database and host settings from config.xml, or set some defaults.
Definition: mythcontext.cpp:531
MythContext::SaveDatabaseParams
bool SaveDatabaseParams(const DatabaseParams &params)
Definition: mythcontext.cpp:1688
Configuration
Definition: configuration.h:21
MythContextPrivate::Init
bool Init(bool gui, bool promptForBackend, bool disableAutoDiscovery, bool ignoreDB)
Definition: mythcontext.cpp:331
GUIStartup
Definition: guistartup.h:51
intResponse
int intResponse(const QString &query, int def)
In an interactive shell, prompt the user to input a number.
Definition: mythmiscutil.cpp:445
MythContextPrivate::m_dbParams
DatabaseParams m_dbParams
Current database host & WOL details.
Definition: mythcontext.cpp:120
MythContextPrivate::HideConnectionFailurePopup
void HideConnectionFailurePopup(void)
Definition: mythcontext.cpp:1417
Configuration::Save
virtual bool Save(void)=0
DatabaseParams::m_wolCommand
QString m_wolCommand
command to use for wake-on-lan
Definition: mythdbparams.h:37
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:930
LOC
#define LOC
Definition: mythcontext.cpp:53
LanguageSelection::prompt
static bool prompt(bool force=false)
Ask the user for the language to use.
Definition: langsettings.cpp:173
BackendSelection::kManualConfigure
@ kManualConfigure
Definition: backendselect.h:43
std
Definition: mythchrono.h:23
DatabaseParams::m_dbUserName
QString m_dbUserName
DB user name.
Definition: mythdbparams.h:25
GENERIC_EXIT_SOCKET_ERROR
#define GENERIC_EXIT_SOCKET_ERROR
Socket error.
Definition: exitcodes.h:18
BackendSelection::Decision
Decision
Definition: backendselect.h:41
GetNotificationCenter
MythNotificationCenter * GetNotificationCenter(void)
Definition: mythmainwindow.cpp:122
mythcontext.h
MythNotificationCenter::UnRegister
void UnRegister(void *from, int id, bool closeimemdiately=false)
Unregister the client.
Definition: mythnotificationcenter.cpp:1374
MythScreenStack::PopScreen
virtual void PopScreen(MythScreenType *screen=nullptr, bool allowFade=true, bool deleteScreen=true)
Definition: mythscreenstack.cpp:84
kDefaultUSN
const QString kDefaultUSN
Definition: backendselect.h:25
GENERIC_EXIT_NO_MYTHCONTEXT
#define GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
Definition: exitcodes.h:13
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:102
Configuration::GetValue
virtual int GetValue(const QString &sSetting, int Default)=0
BackendSelection::Prompt
static Decision Prompt(DatabaseParams *dbParams, Configuration *pConfig)
Definition: backendselect.cpp:48
MythNotification::SetId
void SetId(int Id)
Contains the application registration id.
Definition: mythnotification.cpp:85
MythXMLClient::GetConnectionInfo
UPnPResultCode GetConnectionInfo(const QString &sPin, DatabaseParams *pParams, QString &sMsg)
Definition: mythxmlclient.cpp:35
MythContextPrivate::TempMainWindow
void TempMainWindow(bool languagePrompt=true)
Setup a minimal themed main window, and prompt for user's language.
Definition: mythcontext.cpp:274
MythCoreContext::ActivateSettingsCache
void ActivateSettingsCache(bool activate=true)
Definition: mythcorecontext.cpp:837
MythContextPrivate::m_lastCheck
QDateTime m_lastCheck
Definition: mythcontext.cpp:137
MythContextPrivate::ResetDatabase
void ResetDatabase(void) const
Called when the user changes the DB connection settings.
Definition: mythcontext.cpp:1129
kDefaultPIN
const QString kDefaultPIN
Definition: backendselect.h:24
MythUIHelper::Init
void Init(MythUIMenuCallbacks &cbs)
Definition: mythuihelper.cpp:76
MythContextSlotHandler::OnCloseDialog
void OnCloseDialog(void)
Definition: mythcontext.cpp:703
MythContextPrivate::m_needsBackend
bool m_needsBackend
Definition: mythcontext.cpp:131
MythContextPrivate::processEvents
static void processEvents(void)
Definition: mythcontext.cpp:1460
GUIStartup::m_Setup
bool m_Setup
Definition: guistartup.h:58
MythCoreContext::ClearSettingsCache
void ClearSettingsCache(const QString &myKey=QString(""))
Definition: mythcorecontext.cpp:832
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
DatabaseParams::m_localEnabled
bool m_localEnabled
true if localHostName is not default
Definition: mythdbparams.h:30
UPnPResult_Success
@ UPnPResult_Success
Definition: upnp.h:37
backendselect.h
MythContextPrivate::m_dbHostCp
QString m_dbHostCp
dbHostName backup
Definition: mythcontext.cpp:121
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MythCoreContext::IsWOLAllowed
bool IsWOLAllowed() const
Definition: mythcorecontext.cpp:638
MythUIHelper
Definition: mythuihelper.h:23
MythContextSlotHandler
Definition: mythcontext.h:14
DatabaseParams::m_wolEnabled
bool m_wolEnabled
true if wake-on-lan params are used
Definition: mythdbparams.h:34
MythTranslation::load
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
Definition: mythtranslation.cpp:37
exitcodes.h
SSDPCacheEntries::Count
uint Count(void) const
Definition: ssdpcache.h:45
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
kDefaultMFE
const QString kDefaultMFE
Definition: backendselect.h:23
MThreadPool::globalInstance
static MThreadPool * globalInstance(void)
Definition: mthreadpool.cpp:317
MythCoreContext::GetPluginManager
MythPluginManager * GetPluginManager(void)
Definition: mythcorecontext.cpp:2100
mythmainwindow.h
MythScreenStack::AddScreen
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Definition: mythscreenstack.cpp:50
DatabaseParams::m_localHostName
QString m_localHostName
name used for loading/saving settings
Definition: mythdbparams.h:31
MythCoreContext::SaveLocaleDefaults
void SaveLocaleDefaults(void)
Definition: mythcorecontext.cpp:1875
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:563
MythContextPrivate::m_gui
bool m_gui
Should this context use GUI elements?
Definition: mythcontext.cpp:116
ANDROID_EXCEPTION_CHECK
#define ANDROID_EXCEPTION_CHECK
Definition: audiooutputaudiotrack.cpp:11
gContext
MythContext * gContext
This global variable contains the MythContext instance for the application.
Definition: mythcontext.cpp:59
PortChecker::cancelPortCheck
void cancelPortCheck(void)
Cancel the checkPort operation currently in progress.
Definition: portchecker.cpp:245
MythContext::Init
bool Init(bool gui=true, bool promptForBackend=false, bool disableAutoDiscovery=false, bool ignoreDB=false)
Definition: mythcontext.cpp:1566
MythMainWindow
Definition: mythmainwindow.h:35
DatabaseParams::IsValid
bool IsValid(const QString &source=QString("Unknown")) const
Definition: mythdbparams.cpp:36
MythContextPrivate::m_guiStartup
GUIStartup * m_guiStartup
Definition: mythcontext.cpp:129
SSDPCacheEntries::GetFirst
DeviceLocation * GetFirst(void)
Returns random entry in cache, returns nullptr when list is empty.
Definition: ssdpcache.cpp:81
MythContext::saveSettingsCache
bool saveSettingsCache(void)
Definition: mythcontext.cpp:1693
DestroyMythUI
void DestroyMythUI()
Definition: mythuihelper.cpp:71
GUIStartup::cancelPortCheck
void cancelPortCheck(void)
MythContextPrivate::loadSettingsCacheOverride
void loadSettingsCacheOverride(void) const
Definition: mythcontext.cpp:1503
MythContext::~MythContext
virtual ~MythContext()
Definition: mythcontext.cpp:1658
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:902
MythContextPrivate
Definition: mythcontext.cpp:63
MythNotificationCenter::Queue
bool Queue(const MythNotification &notification)
Queue a notification Queue() is thread-safe and can be called from anywhere.
Definition: mythnotificationcenter.cpp:1350
MythUIMenuCallbacks
Definition: mythuihelper.h:14
GUIStartup::m_Exit
bool m_Exit
Definition: guistartup.h:57
Configuration::SetBoolValue
virtual void SetBoolValue(const QString &sSetting, bool value)=0