MythTV  master
main_helpers.cpp
Go to the documentation of this file.
1 #include "mythconfig.h"
2 #if CONFIG_DARWIN
3  #include <sys/aio.h> // O_SYNC
4 #endif
5 #if CONFIG_SYSTEMD_NOTIFY
6  #include <systemd/sd-daemon.h>
7  #define be_sd_notify(x) \
8  (void)sd_notify(0, x);
9 #else
10  #define be_sd_notify(x)
11 #endif
12 
13 // C++ headers
14 #include <cerrno>
15 #include <csignal>
16 #include <cstdlib>
17 #include <fcntl.h>
18 #include <sys/stat.h>
19 #include <sys/time.h> // for setpriority
20 #include <sys/types.h>
21 #include <unistd.h>
22 
23 #include <QCoreApplication>
24 #include <QFileInfo>
25 #include <QFile>
26 #include <QDir>
27 #include <QMap>
28 
29 #include "tv_rec.h"
30 #include "scheduledrecording.h"
31 #include "autoexpire.h"
32 #include "scheduler.h"
33 #include "mainserver.h"
34 #include "encoderlink.h"
35 #include "remoteutil.h"
36 #include "backendhousekeeper.h"
37 
38 #include "mythcontext.h"
39 #include "mythversion.h"
40 #include "mythdb.h"
41 #include "dbutil.h"
42 #include "exitcodes.h"
43 #include "compat.h"
44 #include "storagegroup.h"
45 #include "programinfo.h"
46 #include "dbcheck.h"
47 #include "jobqueue.h"
48 #include "previewgenerator.h"
49 #include "commandlineparser.h"
50 #include "mythsystemevent.h"
51 #include "main_helpers.h"
52 #include "backendcontext.h"
53 #include "mythtranslation.h"
54 #include "mythtimezone.h"
55 #include "signalhandling.h"
56 #include "hardwareprofile.h"
57 #include "eitcache.h"
58 
59 #include "mediaserver.h"
60 #include "httpstatus.h"
61 #include "mythlogging.h"
62 
63 #define LOC QString("MythBackend: ")
64 #define LOC_WARN QString("MythBackend, Warning: ")
65 #define LOC_ERR QString("MythBackend, Error: ")
66 
67 static MainServer *mainServer = nullptr;
68 
69 bool setupTVs(bool ismaster, bool &error)
70 {
71  error = false;
72  QString localhostname = gCoreContext->GetHostName();
73 
75 
76  if (ismaster)
77  {
78  // Hack to make sure recorded.basename gets set if the user
79  // downgrades to a prior version and creates new entries
80  // without it.
81  if (!query.exec("UPDATE recorded SET basename = CONCAT(chanid, '_', "
82  "DATE_FORMAT(starttime, '%Y%m%d%H%i00'), '_', "
83  "DATE_FORMAT(endtime, '%Y%m%d%H%i00'), '.nuv') "
84  "WHERE basename = '';"))
85  MythDB::DBError("Updating record basename", query);
86 
87  // Hack to make sure record.station gets set if the user
88  // downgrades to a prior version and creates new entries
89  // without it.
90  if (!query.exec("UPDATE channel SET callsign=chanid "
91  "WHERE callsign IS NULL OR callsign='';"))
92  MythDB::DBError("Updating channel callsign", query);
93 
94  if (query.exec("SELECT MIN(chanid) FROM channel;"))
95  {
96  query.first();
97  int min_chanid = query.value(0).toInt();
98  if (!query.exec(QString("UPDATE record SET chanid = %1 "
99  "WHERE chanid IS NULL;").arg(min_chanid)))
100  MythDB::DBError("Updating record chanid", query);
101  }
102  else
103  MythDB::DBError("Querying minimum chanid", query);
104 
105  MSqlQuery records_without_station(MSqlQuery::InitCon());
106  records_without_station.prepare("SELECT record.chanid,"
107  " channel.callsign FROM record LEFT JOIN channel"
108  " ON record.chanid = channel.chanid WHERE record.station='';");
109  if (records_without_station.exec() && records_without_station.next())
110  {
111  MSqlQuery update_record(MSqlQuery::InitCon());
112  update_record.prepare("UPDATE record SET station = :CALLSIGN"
113  " WHERE chanid = :CHANID;");
114  do
115  {
116  update_record.bindValue(":CALLSIGN",
117  records_without_station.value(1));
118  update_record.bindValue(":CHANID",
119  records_without_station.value(0));
120  if (!update_record.exec())
121  {
122  MythDB::DBError("Updating record station", update_record);
123  }
124  } while (records_without_station.next());
125  }
126  }
127 
128  if (!query.exec(
129  "SELECT cardid, parentid, videodevice, hostname, sourceid "
130  "FROM capturecard "
131  "ORDER BY cardid"))
132  {
133  MythDB::DBError("Querying Recorders", query);
134  return false;
135  }
136 
137  vector<uint> cardids;
138  vector<QString> hosts;
139  while (query.next())
140  {
141  uint cardid = query.value(0).toUInt();
142  uint parentid = query.value(1).toUInt();
143  QString videodevice = query.value(2).toString();
144  QString hostname = query.value(3).toString();
145  uint sourceid = query.value(4).toUInt();
146  QString cidmsg = QString("Card[%1](%2)").arg(cardid).arg(videodevice);
147 
148  if (hostname.isEmpty())
149  {
150  LOG(VB_GENERAL, LOG_ERR, cidmsg +
151  " does not have a hostname defined.\n"
152  "Please run setup and confirm all of the capture cards.\n");
153  continue;
154  }
155 
156  // Skip all cards that do not have a video source
157  if (sourceid == 0)
158  {
159  if (parentid == 0)
160  {
161  LOG(VB_GENERAL, LOG_WARNING, cidmsg +
162  " does not have a video source");
163  }
164  continue;
165  }
166 
167  cardids.push_back(cardid);
168  hosts.push_back(hostname);
169  }
170 
171  QWriteLocker tvlocker(&TVRec::s_inputsLock);
172 
173  // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
174  for (size_t i = 0; i < cardids.size(); i++)
175  {
176  if (hosts[i] == localhostname) {
177  // No memory leak. The constructor for TVRec adds the item
178  // to the static map TVRec::s_inputs.
179  new TVRec(cardids[i]);
180  }
181  }
182 
183  for (size_t i = 0; i < cardids.size(); i++)
184  {
185  uint cardid = cardids[i];
186  QString host = hosts[i];
187  QString cidmsg = QString("Card %1").arg(cardid);
188 
189  if (!ismaster)
190  {
191  if (host == localhostname)
192  {
193  TVRec *tv = TVRec::GetTVRec(cardid);
194  if (tv && tv->Init())
195  {
196  auto *enc = new EncoderLink(cardid, tv);
197  tvList[cardid] = enc;
198  }
199  else
200  {
201  LOG(VB_GENERAL, LOG_ERR, "Problem with capture cards. " +
202  cidmsg + " failed init");
203  delete tv;
204  // The master assumes card comes up so we need to
205  // set error and exit if a non-master card fails.
206  error = true;
207  }
208  }
209  }
210  else
211  {
212  if (host == localhostname)
213  {
214  TVRec *tv = TVRec::GetTVRec(cardid);
215  if (tv && tv->Init())
216  {
217  auto *enc = new EncoderLink(cardid, tv);
218  tvList[cardid] = enc;
219  }
220  else
221  {
222  LOG(VB_GENERAL, LOG_ERR, "Problem with capture cards. " +
223  cidmsg + " failed init");
224  delete tv;
225  }
226  }
227  else
228  {
229  auto *enc = new EncoderLink(cardid, nullptr, host);
230  tvList[cardid] = enc;
231  }
232  }
233  }
234 
235  if (tvList.empty())
236  {
237  LOG(VB_GENERAL, LOG_WARNING, LOC +
238  "No valid capture cards are defined in the database.");
239  }
240 
241  return true;
242 }
243 
244 void cleanup(void)
245 {
246  if (mainServer)
247  {
248  mainServer->Stop();
249  qApp->processEvents();
250  }
251 
252  if (gCoreContext)
254 
255  delete sysEventHandler;
256  sysEventHandler = nullptr;
257 
258  delete housekeeping;
259  housekeeping = nullptr;
260 
261  if (gCoreContext)
262  {
263  delete gCoreContext->GetScheduler();
264  gCoreContext->SetScheduler(nullptr);
265  }
266 
267  delete expirer;
268  expirer = nullptr;
269 
270  delete jobqueue;
271  jobqueue = nullptr;
272 
273  delete g_pUPnp;
274  g_pUPnp = nullptr;
275 
276  if (SSDP::Instance())
277  {
279  SSDP::Instance()->wait();
280  }
281 
282  if (TaskQueue::Instance())
283  {
286  }
287 
288  while (!TVRec::s_inputs.empty())
289  {
290  TVRec *rec = *TVRec::s_inputs.begin();
291  delete rec;
292  }
293 
294 
295  delete gContext;
296  gContext = nullptr;
297 
298  delete mainServer;
299  mainServer = nullptr;
300 
301  delete gBackendContext;
302  gBackendContext = nullptr;
303 
304  if (!pidfile.isEmpty())
305  {
306  unlink(pidfile.toLatin1().constData());
307  pidfile.clear();
308  }
309 
311 }
312 
314 {
315  QString eventString;
316 
317  if (cmdline.toBool("event"))
318  eventString = cmdline.toString("event");
319  else if (cmdline.toBool("systemevent"))
320  {
321  eventString = "SYSTEM_EVENT " +
322  cmdline.toString("systemevent") +
323  QString(" SENDER %1").arg(gCoreContext->GetHostName());
324  }
325 
326  if (!eventString.isEmpty())
327  {
329  {
330  gCoreContext->SendMessage(eventString);
331  return GENERIC_EXIT_OK;
332  }
334  }
335 
336  if (cmdline.toBool("setverbose"))
337  {
339  {
340  QString message = "SET_VERBOSE ";
341  message += cmdline.toString("setverbose");
342 
343  gCoreContext->SendMessage(message);
344  LOG(VB_GENERAL, LOG_INFO,
345  QString("Sent '%1' message").arg(message));
346  return GENERIC_EXIT_OK;
347  }
348  LOG(VB_GENERAL, LOG_ERR,
349  "Unable to connect to backend, verbose mask unchanged ");
351  }
352 
353  if (cmdline.toBool("setloglevel"))
354  {
356  {
357  QString message = "SET_LOG_LEVEL ";
358  message += cmdline.toString("setloglevel");
359 
360  gCoreContext->SendMessage(message);
361  LOG(VB_GENERAL, LOG_INFO,
362  QString("Sent '%1' message").arg(message));
363  return GENERIC_EXIT_OK;
364  }
365  LOG(VB_GENERAL, LOG_ERR,
366  "Unable to connect to backend, log level unchanged ");
368  }
369 
370  if (cmdline.toBool("clearcache"))
371  {
373  {
374  gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
375  LOG(VB_GENERAL, LOG_INFO, "Sent CLEAR_SETTINGS_CACHE message");
376  return GENERIC_EXIT_OK;
377  }
378  LOG(VB_GENERAL, LOG_ERR, "Unable to connect to backend, settings "
379  "cache will not be cleared.");
381  }
382 
383  if (cmdline.toBool("printsched") ||
384  cmdline.toBool("testsched"))
385  {
386  auto *sched = new Scheduler(false, &tvList);
387  if (cmdline.toBool("printsched"))
388  {
390  {
391  LOG(VB_GENERAL, LOG_ERR, "Cannot connect to master");
392  delete sched;
394  }
395  std::cout << "Retrieving Schedule from Master backend.\n";
397  }
398  else
399  {
400  std::cout << "Calculating Schedule from database.\n" <<
401  "Inputs, Card IDs, and Conflict info may be invalid "
402  "if you have multiple tuners.\n";
405  }
406 
407  verboseMask |= VB_SCHEDULE;
408  LogLevel_t oldLogLevel = logLevel;
409  logLevel = LOG_DEBUG;
410  sched->PrintList(true);
411  logLevel = oldLogLevel;
412  delete sched;
413  return GENERIC_EXIT_OK;
414  }
415 
416  if (cmdline.toBool("resched"))
417  {
418  bool ok = false;
420  {
421  LOG(VB_GENERAL, LOG_INFO, "Connected to master for reschedule");
422  ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(),
423  "MythBackendCommand");
424  ok = true;
425  }
426  else
427  LOG(VB_GENERAL, LOG_ERR, "Cannot connect to master for reschedule");
428 
430  }
431 
432  if (cmdline.toBool("scanvideos"))
433  {
434  bool ok = false;
436  {
437  gCoreContext->SendReceiveStringList(QStringList() << "SCAN_VIDEOS");
438  LOG(VB_GENERAL, LOG_INFO, "Requested video scan");
439  ok = true;
440  }
441  else
442  LOG(VB_GENERAL, LOG_ERR, "Cannot connect to master for video scan");
443 
445  }
446 
447  if (cmdline.toBool("printexpire"))
448  {
449  expirer = new AutoExpire();
450  expirer->PrintExpireList(cmdline.toString("printexpire"));
451  return GENERIC_EXIT_OK;
452  }
453 
454  // This should never actually be reached..
455  return GENERIC_EXIT_OK;
456 }
457 using namespace MythTZ;
458 
460 {
461  auto *tempMonitorConnection = new MythSocket();
462  if (tempMonitorConnection->ConnectToHost(
465  {
466  if (!gCoreContext->CheckProtoVersion(tempMonitorConnection))
467  {
468  LOG(VB_GENERAL, LOG_ERR, "Master backend is incompatible with "
469  "this backend.\nCannot become a slave.");
470  tempMonitorConnection->DecrRef();
472  }
473 
474  QStringList tempMonitorDone("DONE");
475 
476  QStringList tempMonitorAnnounce(QString("ANN Monitor %1 0")
477  .arg(gCoreContext->GetHostName()));
478  tempMonitorConnection->SendReceiveStringList(tempMonitorAnnounce);
479  if (tempMonitorAnnounce.empty() ||
480  tempMonitorAnnounce[0] == "ERROR")
481  {
482  tempMonitorConnection->DecrRef();
483  tempMonitorConnection = nullptr;
484  if (tempMonitorAnnounce.empty())
485  {
486  LOG(VB_GENERAL, LOG_ERR, LOC +
487  "Failed to open event socket, timeout");
488  }
489  else
490  {
491  LOG(VB_GENERAL, LOG_ERR, LOC +
492  "Failed to open event socket" +
493  ((tempMonitorAnnounce.size() >= 2) ?
494  QString(", error was %1").arg(tempMonitorAnnounce[1]) :
495  QString(", remote error")));
496  }
497  }
498 
499  QStringList timeCheck;
500  if (tempMonitorConnection)
501  {
502  timeCheck.push_back("QUERY_TIME_ZONE");
503  tempMonitorConnection->SendReceiveStringList(timeCheck);
504  tempMonitorConnection->WriteStringList(tempMonitorDone);
505  }
506  if (timeCheck.size() < 3)
507  {
508  if (tempMonitorConnection)
509  tempMonitorConnection->DecrRef();
511  }
512 
513  QDateTime our_time = MythDate::current();
514  QDateTime master_time = MythDate::fromString(timeCheck[2]);
515  int timediff = abs(our_time.secsTo(master_time));
516 
517  if (timediff > 300)
518  {
519  LOG(VB_GENERAL, LOG_ERR,
520  QString("Current time on the master backend differs by "
521  "%1 seconds from time on this system. Exiting.")
522  .arg(timediff));
523  if (tempMonitorConnection)
524  tempMonitorConnection->DecrRef();
526  }
527 
528  if (timediff > 20)
529  {
530  LOG(VB_GENERAL, LOG_WARNING,
531  QString("Time difference between the master "
532  "backend and this system is %1 seconds.")
533  .arg(timediff));
534  }
535  }
536  if (tempMonitorConnection)
537  tempMonitorConnection->DecrRef();
538 
539  return GENERIC_EXIT_OK;
540 }
541 
542 
544 {
545  if (cmdline.toBool("nohousekeeper"))
546  {
547  LOG(VB_GENERAL, LOG_WARNING, LOC +
548  "****** The Housekeeper has been DISABLED with "
549  "the --nohousekeeper option ******");
550  }
551  if (cmdline.toBool("nosched"))
552  {
553  LOG(VB_GENERAL, LOG_WARNING, LOC +
554  "********** The Scheduler has been DISABLED with "
555  "the --nosched option **********");
556  }
557  if (cmdline.toBool("noautoexpire"))
558  {
559  LOG(VB_GENERAL, LOG_WARNING, LOC +
560  "********* Auto-Expire has been DISABLED with "
561  "the --noautoexpire option ********");
562  }
563  if (cmdline.toBool("nojobqueue"))
564  {
565  LOG(VB_GENERAL, LOG_WARNING, LOC +
566  "********* The JobQueue has been DISABLED with "
567  "the --nojobqueue option *********");
568  }
569 }
570 
572 {
574 
576  {
577  LOG(VB_GENERAL, LOG_ERR,
578  "MySQL time zone support is missing. "
579  "Please install it and try again. "
580  "See 'mysql_tzinfo_to_sql' for assistance.");
582  }
583 
584  bool ismaster = gCoreContext->IsMasterHost();
585 
586  if (!UpgradeTVDatabaseSchema(ismaster, ismaster, true))
587  {
588  LOG(VB_GENERAL, LOG_ERR,
589  QString("Couldn't upgrade database to new schema on %1 backend.")
590  .arg(ismaster ? "master" : "slave"));
592  }
593 
594  be_sd_notify("STATUS=Loading translation");
595  MythTranslation::load("mythfrontend");
596 
597  if (!ismaster)
598  {
599  be_sd_notify("STATUS=Connecting to master backend");
600  int ret = connect_to_master();
601  if (ret != GENERIC_EXIT_OK)
602  return ret;
603  }
604 
605  be_sd_notify("STATUS=Get backend server port");
606  int port = gCoreContext->GetBackendServerPort();
607  if (gCoreContext->GetBackendServerIP().isEmpty())
608  {
609  std::cerr << "No setting found for this machine's BackendServerAddr.\n"
610  << "Please run mythtv-setup on this machine.\n"
611  << "Go to page \"1. General\" / \"Host Address Backend Setup\" and examine the values.\n"
612  << "N.B. The default values are correct for a combined frontend/backend machine.\n"
613  << "Press Escape, select \"Save and Exit\" and exit mythtv-setup.\n"
614  << "Then start mythbackend again.\n";
616  }
617 
619 
620  if (ismaster)
621  {
622  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Starting up as the master server.");
623  }
624  else
625  {
626  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Running as a slave backend.");
627  }
628 
629  if (ismaster)
630  {
632  }
633 
635 
636  bool fatal_error = false;
637  bool runsched = setupTVs(ismaster, fatal_error);
638  if (fatal_error)
640 
641  Scheduler *sched = nullptr;
642  if (ismaster)
643  {
644  if (runsched)
645  {
646  be_sd_notify("STATUS=Creating scheduler");
647  sched = new Scheduler(true, &tvList);
648  int err = sched->GetError();
649  if (err)
650  {
651  delete sched;
652  return err;
653  }
654 
655  if (cmdline.toBool("nosched"))
657  }
658 
659  if (!cmdline.toBool("noautoexpire"))
660  {
661  expirer = new AutoExpire(&tvList);
662  if (sched)
664  }
666  }
667 
668  if (!cmdline.toBool("nohousekeeper"))
669  {
670  be_sd_notify("STATUS=Creating housekeeper");
671  housekeeping = new HouseKeeper();
672 
673  if (ismaster)
674  {
680 
681  // only run this task if MythMusic is installed and we have a new enough schema
682  if (gCoreContext->GetNumSetting("MusicDBSchemaVer", 0) >= 1024)
684  }
685 
687 #ifdef __linux__
688  #ifdef CONFIG_BINDINGS_PYTHON
690  #endif
691 #endif
692 
693  housekeeping->Start();
694  }
695 
696  if (!cmdline.toBool("nojobqueue"))
697  jobqueue = new JobQueue(ismaster);
698 
699  // ----------------------------------------------------------------------
700  //
701  // ----------------------------------------------------------------------
702 
703  if (g_pUPnp == nullptr)
704  {
705  be_sd_notify("STATUS=Creating UPnP media server");
706  g_pUPnp = new MediaServer();
707 
708  g_pUPnp->Init(ismaster, cmdline.toBool("noupnp"));
709  }
710 
711  if (cmdline.toBool("dvbv3"))
712  {
713  LOG(VB_GENERAL, LOG_INFO, LOC + "Use legacy DVBv3 API");
714  gCoreContext->SetDVBv3(true);
715  }
716 
717  // ----------------------------------------------------------------------
718  // Setup status server
719  // ----------------------------------------------------------------------
720 
721  HttpStatus *httpStatus = nullptr;
722  HttpServer *pHS = g_pUPnp->GetHttpServer();
723 
724  if (pHS)
725  {
726  LOG(VB_GENERAL, LOG_INFO, "Main::Registering HttpStatus Extension");
727  be_sd_notify("STATUS=Registering HttpStatus Extension");
728 
729  httpStatus = new HttpStatus( &tvList, sched, expirer, ismaster );
730  pHS->RegisterExtension( httpStatus );
731  }
732 
733  be_sd_notify("STATUS=Creating main server");
734  mainServer = new MainServer(
735  ismaster, port, &tvList, sched, expirer);
736 
737  int exitCode = mainServer->GetExitCode();
738  if (exitCode != GENERIC_EXIT_OK)
739  {
740  LOG(VB_GENERAL, LOG_CRIT,
741  "Backend exiting, MainServer initialization error.");
742  cleanup();
743  return exitCode;
744  }
745 
746  if (httpStatus && mainServer)
747  httpStatus->SetMainServer(mainServer);
748 
749  be_sd_notify("STATUS=Check all storage groups");
751 
752  be_sd_notify("STATUS=Sending \"master started\" message");
754  gCoreContext->SendSystemEvent("MASTER_STARTED");
755 
756  // Provide systemd ready notification (for type=notify units)
757  be_sd_notify("READY=1");
758 
761  exitCode = qApp->exec();
764 
766  {
767  gCoreContext->SendSystemEvent("MASTER_SHUTDOWN");
768  qApp->processEvents();
769  }
770 
771  LOG(VB_GENERAL, LOG_NOTICE, "MythBackend exiting");
772  be_sd_notify("STOPPING=1\nSTATUS=Exiting");
773 
774  return exitCode;
775 }
main_helpers.h
Scheduler
Definition: scheduler.h:45
be_sd_notify
#define be_sd_notify(x)
Definition: main_helpers.cpp:10
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:124
hardwareprofile.h
HouseKeeper
Manages registered HouseKeeperTasks and queues tasks for operation.
Definition: housekeeper.h:150
MythCoreContext::SendMessage
void SendMessage(const QString &message)
Definition: mythcorecontext.cpp:1529
AutoExpire::PrintExpireList
void PrintExpireList(const QString &expHost="ALL")
Prints a summary of the files that can be deleted.
Definition: autoexpire.cpp:789
GENERIC_EXIT_OK
#define GENERIC_EXIT_OK
Exited with no error.
Definition: exitcodes.h:10
ThemeUpdateTask
Definition: backendhousekeeper.h:42
Scheduler::GetError
int GetError(void) const
Definition: scheduler.h:115
dbutil.h
backendcontext.h
EITCache::ClearChannelLocks
static MTV_PUBLIC void ClearChannelLocks(void)
Removes old channel locks, use it only at master backend start.
Definition: eitcache.cpp:431
sysEventHandler
MythSystemEventHandler * sysEventHandler
Definition: backendcontext.cpp:15
error
static void error(const char *str,...)
Definition: vbi.cpp:42
MediaServer
Definition: mediaserver.h:32
MythCoreContext::GetScheduler
MythScheduler * GetScheduler(void)
Definition: mythcorecontext.cpp:1889
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:1383
UpgradeTVDatabaseSchema
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
Definition: dbcheck.cpp:361
HttpStatus
Definition: httpstatus.h:42
connect_to_master
int connect_to_master(void)
Definition: main_helpers.cpp:459
TVRec::Init
bool Init(void)
Performs instance initialization, returns true on success.
Definition: tv_rec.cpp:136
BackendContext
Definition: backendcontext.h:42
MythCoreContext::ConnectToMasterServer
bool ConnectToMasterServer(bool blockingClient=true, bool openEventSocket=true)
Definition: mythcorecontext.cpp:381
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:303
logLevel
LogLevel_t logLevel
Definition: logging.cpp:88
TaskQueue::RequestTerminate
void RequestTerminate()
Definition: taskqueue.cpp:101
jobqueue
JobQueue * jobqueue
Definition: backendcontext.cpp:9
tvList
QMap< int, EncoderLink * > tvList
Definition: backendcontext.cpp:7
HttpServer::RegisterExtension
void RegisterExtension(HttpServerExtension *pExtension)
Definition: httpserver.cpp:318
MythCoreContext::SetScheduler
void SetScheduler(MythScheduler *sched)
Definition: mythcorecontext.cpp:1884
Scheduler::FillRecordListFromDB
void FillRecordListFromDB(uint recordid=0)
Definition: scheduler.cpp:485
GENERIC_EXIT_DB_NOTIMEZONE
#define GENERIC_EXIT_DB_NOTIMEZONE
Missing DB time zone support.
Definition: exitcodes.h:36
httpstatus.h
LOC
#define LOC
Definition: main_helpers.cpp:63
RadioStreamUpdateTask
Definition: backendhousekeeper.h:30
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:197
MainServer
Definition: mainserver.h:113
AutoExpire
Used to expire recordings to make space for new recordings.
Definition: autoexpire.h:60
Scheduler::DisableScheduling
void DisableScheduling(void)
Definition: scheduler.h:106
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
UPnp::GetHttpServer
HttpServer * GetHttpServer()
Definition: upnp.h:134
MythCoreContext::CheckProtoVersion
bool CheckProtoVersion(MythSocket *socket, std::chrono::milliseconds timeout=kMythSocketLongTimeout, bool error_dialog_desired=false)
Definition: mythcorecontext.cpp:1679
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
print_warnings
void print_warnings(const MythBackendCommandLineParser &cmdline)
Definition: main_helpers.cpp:543
mythsystemevent.h
HouseKeeper::RegisterTask
void RegisterTask(HouseKeeperTask *task)
Definition: housekeeper.cpp:635
gBackendContext
BackendContext * gBackendContext
Definition: backendcontext.cpp:12
HttpStatus::SetMainServer
void SetMainServer(MainServer *mainServer)
Definition: httpstatus.h:88
remoteutil.h
scheduler.h
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
LogCleanerTask
Definition: backendhousekeeper.h:7
mythversion.h
MythSocket
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
SSDP::Instance
static SSDP * Instance()
Definition: ssdp.cpp:52
run_backend
int run_backend(MythBackendCommandLineParser &cmdline)
Definition: main_helpers.cpp:571
MythCoreContext::IsMasterBackend
bool IsMasterBackend(void)
is this the actual MBE process
Definition: mythcorecontext.cpp:719
autoexpire.h
expirer
AutoExpire * expirer
Definition: backendcontext.cpp:8
programinfo.h
g_pUPnp
MediaServer * g_pUPnp
Definition: backendcontext.cpp:11
mythlogging.h
handle_command
int handle_command(const MythBackendCommandLineParser &cmdline)
Definition: main_helpers.cpp:313
dbcheck.h
MythCoreContext::GetBackendServerPort
int GetBackendServerPort(void)
Returns the locally defined backend control port.
Definition: mythcorecontext.cpp:1088
MythCoreContext::SendSystemEvent
void SendSystemEvent(const QString &msg)
Definition: mythcorecontext.cpp:1556
MythCoreContext::GetMasterServerIP
QString GetMasterServerIP(void)
Returns the Master Backend IP address If the address is an IPv6 address, the scope Id is removed.
Definition: mythcorecontext.cpp:990
signalhandling.h
verboseMask
uint64_t verboseMask
Definition: logging.cpp:100
MSqlQuery::first
bool first(void)
Wrap QSqlQuery::first() so we can display the query results.
Definition: mythdbcon.cpp:822
TaskQueue::Instance
static TaskQueue * Instance()
Definition: taskqueue.cpp:58
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
compat.h
MythCoreContext::GetBackendServerIP
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
Definition: mythcorecontext.cpp:1028
MythCoreContext::SetDVBv3
void SetDVBv3(bool dvbv3)
Definition: mythcorecontext.h:326
eitcache.h
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:200
GENERIC_EXIT_SETUP_ERROR
#define GENERIC_EXIT_SETUP_ERROR
Incorrectly setup system.
Definition: exitcodes.h:21
Scheduler::SetExpirer
void SetExpirer(AutoExpire *autoExpirer)
Definition: scheduler.h:55
mythtranslation.h
MythTZ
Definition: mythtimezone.cpp:21
setupTVs
bool setupTVs(bool ismaster, bool &error)
Definition: main_helpers.cpp:69
HardwareProfileTask
Definition: hardwareprofile.h:52
scheduledrecording.h
ArtworkTask
Definition: backendhousekeeper.h:57
DBUtil::CheckTimeZoneSupport
static bool CheckTimeZoneSupport(void)
Check if MySQL has working timz zone support.
Definition: dbutil.cpp:866
storagegroup.h
jobqueue.h
Scheduler::PrintList
void PrintList(bool onlyFutureRecordings=false)
Definition: scheduler.h:96
cleanup
void cleanup(void)
Definition: main_helpers.cpp:244
TVRec::s_inputsLock
static QReadWriteLock s_inputsLock
Definition: tv_rec.h:435
commandlineparser.h
uint
unsigned int uint
Definition: compat.h:140
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
pidfile
QString pidfile
Definition: backendcontext.cpp:13
JobQueueRecoverTask
Definition: backendhousekeeper.h:70
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:936
MediaServer::Init
void Init(bool bIsMaster, bool bDisableUPnp=false)
Definition: mediaserver.cpp:69
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:30
housekeeping
HouseKeeper * housekeeping
Definition: backendcontext.cpp:10
MainServer::GetExitCode
int GetExitCode() const
Definition: mainserver.h:152
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
sched
Scheduler * sched
backendhousekeeper.h
mediaserver.h
cmdline
MythCommFlagCommandLineParser cmdline
Definition: mythtv/programs/mythcommflag/main.cpp:74
CleanupTask
Definition: backendhousekeeper.h:15
MythCommandLineParser::toString
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
Definition: mythcommandlineparser.cpp:2252
MythCommandLineParser::toBool
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
Definition: mythcommandlineparser.cpp:2095
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:893
GENERIC_EXIT_SOCKET_ERROR
#define GENERIC_EXIT_SOCKET_ERROR
Socket error.
Definition: exitcodes.h:18
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:145
mythcontext.h
GENERIC_EXIT_NO_MYTHCONTEXT
#define GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
Definition: exitcodes.h:13
tv_rec.h
HttpServer
Definition: httpserver.h:110
mainserver.h
JobQueue
Definition: jobqueue.h:126
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:862
MythBackendCommandLineParser
Definition: mythbackend/commandlineparser.h:7
mainServer
static MainServer * mainServer
Definition: main_helpers.cpp:67
MythCoreContext::IsMasterHost
bool IsMasterHost(void)
is this the same host as the master
Definition: mythcorecontext.cpp:683
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
previewgenerator.h
GENERIC_EXIT_CONNECT_ERROR
#define GENERIC_EXIT_CONNECT_ERROR
Can't connect to master backend.
Definition: exitcodes.h:20
MythFillDatabaseTask
Definition: backendhousekeeper.h:79
ProgramInfo::CheckProgramIDAuthorities
static void CheckProgramIDAuthorities(void)
Definition: programinfo.cpp:2370
MythTranslation::load
static void load(const QString &module_name)
Load a QTranslator for the user's preferred language.
Definition: mythtranslation.cpp:37
exitcodes.h
MainServer::Stop
void Stop(void)
Definition: mainserver.cpp:356
MythSystemEventHandler
Handles incoming MythSystemEvent messages.
Definition: mythsystemevent.h:24
Scheduler::FillRecordListFromMaster
void FillRecordListFromMaster(void)
Definition: scheduler.cpp:568
ScheduledRecording::RescheduleMatch
static void RescheduleMatch(uint recordid, uint sourceid, uint mplexid, const QDateTime &maxstarttime, const QString &why)
Definition: scheduledrecording.h:17
StorageGroup::CheckAllStorageGroupDirs
static void CheckAllStorageGroupDirs(void)
Definition: storagegroup.cpp:729
gContext
MythContext * gContext
This global variable contains the MythContext instance for the application.
Definition: mythcontext.cpp:64
HouseKeeper::Start
void Start(void)
Definition: housekeeper.cpp:669
mythtimezone.h
SignalHandler::Done
static void Done(void)
Definition: signalhandling.cpp:131
MythCoreContext::SetExiting
void SetExiting(bool exiting=true)
Definition: mythcorecontext.cpp:2096
TVRec::GetTVRec
static TVRec * GetTVRec(uint inputid)
Definition: tv_rec.cpp:4830
SSDP::RequestTerminate
void RequestTerminate(void)
Definition: ssdp.cpp:134
GENERIC_EXIT_INVALID_TIME
#define GENERIC_EXIT_INVALID_TIME
Invalid time.
Definition: exitcodes.h:22
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837
TVRec::s_inputs
static QMap< uint, TVRec * > s_inputs
Definition: tv_rec.h:436
GENERIC_EXIT_DB_OUTOFDATE
#define GENERIC_EXIT_DB_OUTOFDATE
Database needs upgrade.
Definition: exitcodes.h:16