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