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