MythTV  master
v2myth.cpp
Go to the documentation of this file.
1 // Qt
2 #include <QDir>
3 #include <QFileInfo>
4 #include <QCryptographicHash>
5 #include <QHostAddress>
6 #include <QUdpSocket>
7 
8 // MythTV
9 #include "libmythbase/dbutil.h"
13 #include "libmythbase/mythdate.h"
14 #include "libmythbase/mythdb.h"
15 #include "libmythbase/mythdbcon.h"
18 #include "libmythbase/mythversion.h"
20 #include "libmythbase/version.h"
21 #include "libmythtv/tv_rec.h"
22 
23 // MythBackend
24 #include "backendcontext.h"
25 #include "scheduler.h"
26 #include "v2databaseInfo.h"
27 #include "v2myth.h"
28 #include "v2serviceUtil.h"
29 #include "v2versionInfo.h"
30 #include "v2wolInfo.h"
31 
32 // This will be initialised in a thread safe manner on first use
34  (MYTH_HANDLE, V2Myth::staticMetaObject, &V2Myth::RegisterCustomTypes))
35 
37 {
38  qRegisterMetaType<V2ConnectionInfo*>("V2ConnectionInfo");
39  qRegisterMetaType<V2VersionInfo*>("V2VersionInfo");
40  qRegisterMetaType<V2DatabaseInfo*>("V2DatabaseInfo");
41  qRegisterMetaType<V2WOLInfo*>("V2WOLInfo");
42  qRegisterMetaType<V2StorageGroupDirList*>("V2StorageGroupDirList");
43  qRegisterMetaType<V2StorageGroupDir*>("V2StorageGroupDir");
44  qRegisterMetaType<V2TimeZoneInfo*>("V2TimeZoneInfo");
45  qRegisterMetaType<V2LogMessage*>("V2LogMessage");
46  qRegisterMetaType<V2LogMessageList*>("V2LogMessageList");
47  qRegisterMetaType<V2LabelValue*>("V2LabelValue");
48  qRegisterMetaType<V2Frontend*>("V2Frontend");
49  qRegisterMetaType<V2FrontendList*>("V2FrontendList");
50  qRegisterMetaType<V2SettingList*>("V2SettingList");
51  qRegisterMetaType<V2BackendInfo*>("V2BackendInfo");
52  qRegisterMetaType<V2EnvInfo*>("V2EnvInfo");
53  qRegisterMetaType<V2LogInfo*>("V2LogInfo");
54  qRegisterMetaType<V2BuildInfo*>("V2BuildInfo");
55 }
56 
57 
59  : MythHTTPService(s_service)
60 {
61 }
62 
64 //
66 
68 {
69  QString sSecurityPin = gCoreContext->GetSetting( "SecurityPin", "");
70 
71  if ( sSecurityPin.isEmpty() )
72  throw( QString( "No Security Pin assigned. Run mythtv-setup to set one." ));
73  //SB: UPnPResult_HumanInterventionRequired,
74 
75  if ((sSecurityPin != "0000" ) && ( sPin != sSecurityPin ))
76  throw( QString( "Not Authorized" ));
77  //SB: UPnPResult_ActionNotAuthorized );
78 
79  DatabaseParams params = GetMythDB()->GetDatabaseParams();
80 
81  // ----------------------------------------------------------------------
82  // Check for DBHostName of "localhost" and change to public name or IP
83  // ----------------------------------------------------------------------
84 
85  QString sServerIP = gCoreContext->GetBackendServerIP();
86  //QString sPeerIP = pRequest->GetPeerAddress();
87 
88  if ((params.m_dbHostName.compare("localhost",Qt::CaseInsensitive)==0
89  || params.m_dbHostName == "127.0.0.1"
90  || params.m_dbHostName == "::1")
91  && !sServerIP.isEmpty()) // &&
92  //(sServerIP != sPeerIP ))
93  {
94  params.m_dbHostName = sServerIP;
95  }
96 
97  // If dbHostName is an IPV6 address with scope,
98  // remove the scope. Unescaped % signs are an
99  // xml violation
100  QString dbHostName(params.m_dbHostName);
101  QHostAddress addr;
102  if (addr.setAddress(dbHostName))
103  {
104  addr.setScopeId(QString());
105  dbHostName = addr.toString();
106  }
107  // ----------------------------------------------------------------------
108  // Create and populate a ConnectionInfo object
109  // ----------------------------------------------------------------------
110 
111  auto *pInfo = new V2ConnectionInfo();
112  V2DatabaseInfo *pDatabase = pInfo->Database();
113  V2WOLInfo *pWOL = pInfo->WOL();
114  V2VersionInfo *pVersion = pInfo->Version();
115 
116  pDatabase->setHost ( dbHostName );
117  pDatabase->setPing ( params.m_dbHostPing );
118  pDatabase->setPort ( params.m_dbPort );
119  pDatabase->setUserName ( params.m_dbUserName );
120  pDatabase->setPassword ( params.m_dbPassword );
121  pDatabase->setName ( params.m_dbName );
122  pDatabase->setType ( params.m_dbType );
123  pDatabase->setLocalEnabled ( params.m_localEnabled );
124  pDatabase->setLocalHostName( params.m_localHostName );
125 
126  pWOL->setEnabled ( params.m_wolEnabled );
127  pWOL->setReconnect ( params.m_wolReconnect.count() );
128  pWOL->setRetry ( params.m_wolRetry );
129  pWOL->setCommand ( params.m_wolCommand );
130 
131  pVersion->setVersion ( MYTH_SOURCE_VERSION );
132  pVersion->setBranch ( MYTH_SOURCE_PATH );
133  pVersion->setProtocol ( MYTH_PROTO_VERSION );
134  pVersion->setBinary ( MYTH_BINARY_VERSION );
135  pVersion->setSchema ( MYTH_DATABASE_VERSION );
136 
137  // ----------------------------------------------------------------------
138  // Return the pointer... caller is responsible to delete it!!!
139  // ----------------------------------------------------------------------
140 
141  return pInfo;
142 }
143 
145 //
147 bool V2Myth::SetConnectionInfo(const QString &Host, const QString &UserName, const QString &Password, const QString &Name, int Port, bool DoTest)
148 {
149  bool bResult = false;
150 
151  QString db("mythconverg");
152  int port = 3306;
153 
154  if (!Name.isEmpty())
155  db = Name;
156 
157  if (Port != 0)
158  port = Port;
159 
160  if (DoTest && !TestDatabase(Host, UserName, Password, db, port))
161  throw( QString( "Database test failed. Not saving database connection information." ));
162 
163  DatabaseParams dbparms;
164  dbparms.m_dbName = db;
165  dbparms.m_dbUserName = UserName;
166  dbparms.m_dbPassword = Password;
167  dbparms.m_dbHostName = Host;
168  dbparms.m_dbPort = port;
169 
170  // Just use some sane defaults for these values
171  dbparms.m_wolEnabled = false;
172  dbparms.m_wolReconnect = 1s;
173  dbparms.m_wolRetry = 3;
174  dbparms.m_wolCommand = QString();
175 
176  bResult = gContext->SaveDatabaseParams(dbparms);
177 
178  return bResult;
179 }
180 
182 //
184 
186 {
187  if (!gCoreContext)
188  throw( QString( "No MythCoreContext in GetHostName." ));
189 
190  return gCoreContext->GetHostName();
191 }
192 
194 //
196 
197 QStringList V2Myth::GetHosts( )
198 {
199  MSqlQuery query(MSqlQuery::InitCon());
200 
201  if (!query.isConnected())
202  throw( QString( "Database not open while trying to load list of hosts" ));
203 
204  query.prepare(
205  "SELECT DISTINCTROW hostname "
206  "FROM settings "
207  "WHERE (not isNull( hostname ))");
208 
209  if (!query.exec())
210  {
211  MythDB::DBError("MythAPI::GetHosts()", query);
212 
213  throw( QString( "Database Error executing query." ));
214  }
215 
216  // ----------------------------------------------------------------------
217  // return the results of the query
218  // ----------------------------------------------------------------------
219 
220  QStringList oList;
221 
222  while (query.next())
223  oList.append( query.value(0).toString() );
224 
225  return oList;
226 }
227 
229 //
231 
232 QStringList V2Myth::GetKeys()
233 {
234  MSqlQuery query(MSqlQuery::InitCon());
235 
236  if (!query.isConnected())
237  throw( QString("Database not open while trying to load settings"));
238 
239  query.prepare("SELECT DISTINCTROW value FROM settings;" );
240 
241  if (!query.exec())
242  {
243  MythDB::DBError("MythAPI::GetKeys()", query);
244 
245  throw( QString( "Database Error executing query." ));
246  }
247 
248  // ----------------------------------------------------------------------
249  // return the results of the query
250  // ----------------------------------------------------------------------
251 
252  QStringList oResults;
253 
254  //pResults->setObjectName( "KeyList" );
255 
256  while (query.next())
257  oResults.append( query.value(0).toString() );
258 
259  return oResults;
260 }
261 
263 // DirListing gets a list of subdirectories
265 
266 QStringList V2Myth::GetDirListing ( const QString &DirName)
267 {
268  QDir directory(DirName);
269  return directory.entryList(QDir::AllDirs|QDir::NoDotAndDotDot, QDir::Name);
270 }
271 
272 
274 //
277  const QString &sHostName )
278 {
279  MSqlQuery query(MSqlQuery::InitCon());
280 
281  if (!query.isConnected())
282  throw( QString("Database not open while trying to list "
283  "Storage Group Dirs"));
284 
285  if (!sGroupName.isEmpty() && !sHostName.isEmpty())
286  {
287  query.prepare("SELECT id, groupname, hostname, dirname "
288  "FROM storagegroup "
289  "WHERE groupname = :GROUP AND hostname = :HOST "
290  "ORDER BY groupname, hostname, dirname" );
291  query.bindValue(":HOST", sHostName);
292  query.bindValue(":GROUP", sGroupName);
293  }
294  else if (!sHostName.isEmpty())
295  {
296  query.prepare("SELECT id, groupname, hostname, dirname "
297  "FROM storagegroup "
298  "WHERE hostname = :HOST "
299  "ORDER BY groupname, hostname, dirname" );
300  query.bindValue(":HOST", sHostName);
301  }
302  else if (!sGroupName.isEmpty())
303  {
304  query.prepare("SELECT id, groupname, hostname, dirname "
305  "FROM storagegroup "
306  "WHERE groupname = :GROUP "
307  "ORDER BY groupname, hostname, dirname" );
308  query.bindValue(":GROUP", sGroupName);
309  }
310  else
311  {
312  query.prepare("SELECT id, groupname, hostname, dirname "
313  "FROM storagegroup "
314  "ORDER BY groupname, hostname, dirname" );
315  }
316 
317  if (!query.exec())
318  {
319  MythDB::DBError("MythAPI::GetStorageGroupDirs()", query);
320 
321  throw( QString( "Database Error executing query." ));
322  }
323 
324  // ----------------------------------------------------------------------
325  // return the results of the query plus R/W and size information
326  // ----------------------------------------------------------------------
327 
328  auto* pList = new V2StorageGroupDirList();
329 
330  while (query.next())
331  {
332  V2StorageGroupDir *pStorageGroupDir = pList->AddNewStorageGroupDir();
333  QFileInfo fi(query.value(3).toString());
334  int64_t free = 0;
335  int64_t total = 0;
336  int64_t used = 0;
337 
338  free = getDiskSpace(query.value(3).toString(), total, used);
339 
340  pStorageGroupDir->setId ( query.value(0).toInt() );
341  pStorageGroupDir->setGroupName ( query.value(1).toString() );
342  pStorageGroupDir->setHostName ( query.value(2).toString() );
343  pStorageGroupDir->setDirName ( query.value(3).toString() );
344  pStorageGroupDir->setDirRead ( fi.isReadable() );
345  pStorageGroupDir->setDirWrite ( fi.isWritable() );
346  pStorageGroupDir->setKiBFree ( free );
347  }
348 
349  return pList;
350 }
351 
353 //
355 
356 bool V2Myth::AddStorageGroupDir( const QString &sGroupName,
357  const QString &sDirName,
358  const QString &sHostName )
359 {
360  MSqlQuery query(MSqlQuery::InitCon());
361 
362  if (!query.isConnected())
363  throw( QString("Database not open while trying to add Storage Group "
364  "dir"));
365 
366  if (sGroupName.isEmpty())
367  throw ( QString( "Storage Group Required" ));
368 
369  if (sDirName.isEmpty())
370  throw ( QString( "Directory Name Required" ));
371 
372  if (sHostName.isEmpty())
373  throw ( QString( "HostName Required" ));
374 
375  query.prepare("SELECT COUNT(*) "
376  "FROM storagegroup "
377  "WHERE groupname = :GROUPNAME "
378  "AND dirname = :DIRNAME "
379  "AND hostname = :HOSTNAME;");
380  query.bindValue(":GROUPNAME", sGroupName );
381  query.bindValue(":DIRNAME" , sDirName );
382  query.bindValue(":HOSTNAME" , sHostName );
383  if (!query.exec())
384  {
385  MythDB::DBError("MythAPI::AddStorageGroupDir()", query);
386 
387  throw( QString( "Database Error executing query." ));
388  }
389 
390  if (query.next())
391  {
392  if (query.value(0).toInt() > 0)
393  return false;
394  }
395 
396  query.prepare("INSERT storagegroup "
397  "( groupname, dirname, hostname ) "
398  "VALUES "
399  "( :GROUPNAME, :DIRNAME, :HOSTNAME );");
400  query.bindValue(":GROUPNAME", sGroupName );
401  query.bindValue(":DIRNAME" , sDirName );
402  query.bindValue(":HOSTNAME" , sHostName );
403 
404  if (!query.exec())
405  {
406  MythDB::DBError("MythAPI::AddStorageGroupDir()", query);
407 
408  throw( QString( "Database Error executing query." ));
409  }
410 
411  return true;
412 }
413 
415 //
417 
418 bool V2Myth::RemoveStorageGroupDir( const QString &sGroupName,
419  const QString &sDirName,
420  const QString &sHostName )
421 {
422  MSqlQuery query(MSqlQuery::InitCon());
423 
424  if (!query.isConnected())
425  throw( QString("Database not open while trying to remove Storage "
426  "Group dir"));
427 
428  if (sGroupName.isEmpty())
429  throw ( QString( "Storage Group Required" ));
430 
431  if (sDirName.isEmpty())
432  throw ( QString( "Directory Name Required" ));
433 
434  if (sHostName.isEmpty())
435  throw ( QString( "HostName Required" ));
436 
437  query.prepare("DELETE "
438  "FROM storagegroup "
439  "WHERE groupname = :GROUPNAME "
440  "AND dirname = :DIRNAME "
441  "AND hostname = :HOSTNAME;");
442  query.bindValue(":GROUPNAME", sGroupName );
443  query.bindValue(":DIRNAME" , sDirName );
444  query.bindValue(":HOSTNAME" , sHostName );
445  if (!query.exec())
446  {
447  MythDB::DBError("MythAPI::RemoveStorageGroupDir()", query);
448 
449  throw( QString( "Database Error executing query." ));
450  }
451 
452  return true;
453 }
454 
456 //
458 
460 {
461  auto *pResults = new V2TimeZoneInfo();
462 
463  pResults->setTimeZoneID( MythTZ::getTimeZoneID() );
464  pResults->setUTCOffset( MythTZ::calc_utc_offset() );
465  pResults->setCurrentDateTime( MythDate::current(true) );
466 
467  return pResults;
468 }
469 
471 //
473 
474 QString V2Myth::GetFormatDate(const QDateTime &Date, bool ShortDate)
475 {
477  if (ShortDate)
479 
480  return MythDate::toString(Date, dateFormat);
481 }
482 
484 //
486 
487 QString V2Myth::GetFormatDateTime(const QDateTime &DateTime, bool ShortDate)
488 {
490  if (ShortDate)
492 
493  return MythDate::toString(DateTime, dateFormat);
494 }
495 
497 //
499 
500 QString V2Myth::GetFormatTime(const QDateTime &Time)
501 {
502  return MythDate::toString(Time, MythDate::kTime);
503 }
504 
506 //
508 
509 QDateTime V2Myth::ParseISODateString(const QString& DateTime)
510 {
511  auto dateTime = QDateTime::fromString(DateTime, Qt::ISODate);
512 
513  if (!dateTime.isValid())
514  throw QString( "Unable to parse DateTime" );
515 
516  return dateTime;
517 }
518 
520 //
522 
523 V2LogMessageList* V2Myth::GetLogs( const QString &HostName,
524  const QString &Application,
525  int PID,
526  int TID,
527  const QString &Thread,
528  const QString &Filename,
529  int Line,
530  const QString &Function,
531  const QDateTime &FromTime,
532  const QDateTime &ToTime,
533  const QString &Level,
534  const QString &MsgContains )
535 {
536  auto *pList = new V2LogMessageList();
537 
538  MSqlQuery query(MSqlQuery::InitCon());
539 
540  // Get host name list
541  QString sql = "SELECT DISTINCT host FROM logging ORDER BY host ASC";
542  if (!query.exec(sql))
543  {
544  MythDB::DBError("Retrieving log host names", query);
545  delete pList;
546  throw( QString( "Database Error executing query." ));
547  }
548  while (query.next())
549  {
550  V2LabelValue *pLabelValue = pList->AddNewHostName();
551  QString availableHostName = query.value(0).toString();
552  pLabelValue->setValue ( availableHostName );
553  pLabelValue->setActive ( availableHostName == HostName );
554  pLabelValue->setSelected( availableHostName == HostName );
555  }
556  // Get application list
557  sql = "SELECT DISTINCT application FROM logging ORDER BY application ASC";
558  if (!query.exec(sql))
559  {
560  MythDB::DBError("Retrieving log applications", query);
561  delete pList;
562  throw( QString( "Database Error executing query." ));
563  }
564  while (query.next())
565  {
566  V2LabelValue *pLabelValue = pList->AddNewApplication();
567  QString availableApplication = query.value(0).toString();
568  pLabelValue->setValue ( availableApplication );
569  pLabelValue->setActive ( availableApplication == Application );
570  pLabelValue->setSelected( availableApplication == Application );
571  }
572 
573  if (!HostName.isEmpty() && !Application.isEmpty())
574  {
575  // Get log messages
576  sql = "SELECT host, application, pid, tid, thread, filename, "
577  " line, function, msgtime, level, message "
578  " FROM logging "
579  " WHERE host = COALESCE(:HOSTNAME, host) "
580  " AND application = COALESCE(:APPLICATION, application) "
581  " AND pid = COALESCE(:PID, pid) "
582  " AND tid = COALESCE(:TID, tid) "
583  " AND thread = COALESCE(:THREAD, thread) "
584  " AND filename = COALESCE(:FILENAME, filename) "
585  " AND line = COALESCE(:LINE, line) "
586  " AND function = COALESCE(:FUNCTION, function) "
587  " AND msgtime >= COALESCE(:FROMTIME, msgtime) "
588  " AND msgtime <= COALESCE(:TOTIME, msgtime) "
589  " AND level <= COALESCE(:LEVEL, level) "
590  ;
591  if (!MsgContains.isEmpty())
592  {
593  sql.append(" AND message LIKE :MSGCONTAINS ");
594  }
595  sql.append(" ORDER BY msgtime ASC;");
596 
597 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
598  QVariant ullNull = QVariant(QVariant::ULongLong);
599 #else
600  QVariant ullNull = QVariant(QMetaType(QMetaType::ULongLong));
601 #endif
602  query.prepare(sql);
603 
604  query.bindValue(":HOSTNAME", (HostName.isEmpty()) ? QString() : HostName);
605  query.bindValue(":APPLICATION", (Application.isEmpty()) ? QString() :
606  Application);
607  query.bindValue(":PID", ( PID == 0 ) ? ullNull : (qint64)PID);
608  query.bindValue(":TID", ( TID == 0 ) ? ullNull : (qint64)TID);
609  query.bindValue(":THREAD", (Thread.isEmpty()) ? QString() : Thread);
610  query.bindValue(":FILENAME", (Filename.isEmpty()) ? QString() : Filename);
611  query.bindValue(":LINE", ( Line == 0 ) ? ullNull : (qint64)Line);
612  query.bindValue(":FUNCTION", (Function.isEmpty()) ? QString() : Function);
613  query.bindValue(":FROMTIME", (FromTime.isValid()) ? FromTime : QDateTime());
614  query.bindValue(":TOTIME", (ToTime.isValid()) ? ToTime : QDateTime());
615  query.bindValue(":LEVEL", (Level.isEmpty()) ? ullNull :
616  (qint64)logLevelGet(Level));
617 
618  if (!MsgContains.isEmpty())
619  {
620  query.bindValue(":MSGCONTAINS", "%" + MsgContains + "%" );
621  }
622 
623  if (!query.exec())
624  {
625  MythDB::DBError("Retrieving log messages", query);
626  delete pList;
627  throw( QString( "Database Error executing query." ));
628  }
629 
630  while (query.next())
631  {
632  V2LogMessage *pLogMessage = pList->AddNewLogMessage();
633 
634  pLogMessage->setHostName( query.value(0).toString() );
635  pLogMessage->setApplication( query.value(1).toString() );
636  pLogMessage->setPID( query.value(2).toInt() );
637  pLogMessage->setTID( query.value(3).toInt() );
638  pLogMessage->setThread( query.value(4).toString() );
639  pLogMessage->setFilename( query.value(5).toString() );
640  pLogMessage->setLine( query.value(6).toInt() );
641  pLogMessage->setFunction( query.value(7).toString() );
642  pLogMessage->setTime(MythDate::as_utc(query.value(8).toDateTime()));
643  pLogMessage->setLevel( logLevelGetName(
644  (LogLevel_t)query.value(9).toInt()) );
645  pLogMessage->setMessage( query.value(10).toString() );
646  }
647  }
648 
649  return pList;
650 }
651 
653 //
655 
657 {
658  auto *pList = new V2FrontendList();
659 
660  FillFrontendList(pList->GetFrontends(), pList,
661  OnLine);
662  return pList;
663 }
664 
666 //
668 
669 QString V2Myth::GetSetting( const QString &sHostName,
670  const QString &sKey,
671  const QString &sDefault )
672 {
673  if (sKey.isEmpty())
674  throw( QString("Missing or empty Key (settings.value)") );
675 
676  if (sHostName == "_GLOBAL_")
677  {
678  MSqlQuery query(MSqlQuery::InitCon());
679 
680  query.prepare("SELECT data FROM settings "
681  "WHERE value = :VALUE "
682  "AND (hostname IS NULL)" );
683 
684  query.bindValue(":VALUE", sKey );
685 
686  if (!query.exec())
687  {
688  MythDB::DBError("API Myth/GetSetting ", query);
689  throw( QString( "Database Error executing query." ));
690  }
691 
692  return query.next() ? query.value(0).toString() : sDefault;
693  }
694 
695  QString hostname = sHostName;
696 
697  if (sHostName.isEmpty())
699 
700  return gCoreContext->GetSettingOnHost(sKey, hostname, sDefault);
701 }
702 
704 //
706 
707 V2SettingList* V2Myth::GetSettingList(const QString &sHostName)
708 {
709 
710  MSqlQuery query(MSqlQuery::InitCon());
711 
712  if (!query.isConnected())
713  {
714  throw( QString("Database not open while trying to load settings for host: %1")
715  .arg( sHostName ));
716  }
717 
718  auto *pList = new V2SettingList();
719 
720  pList->setHostName ( sHostName );
721 
722  // ------------------------------------------------------------------
723  // Looking to return all Setting for supplied hostname
724  // ------------------------------------------------------------------
725 
726  if (sHostName.isEmpty())
727  {
728  query.prepare("SELECT value, data FROM settings "
729  "WHERE (hostname IS NULL)" );
730  }
731  else
732  {
733  query.prepare("SELECT value, data FROM settings "
734  "WHERE (hostname = :HOSTNAME)" );
735 
736  query.bindValue(":HOSTNAME", sHostName );
737  }
738 
739  if (!query.exec())
740  {
741  // clean up unused object we created.
742 
743  delete pList;
744 
745  MythDB::DBError("MythAPI::GetSetting() w/o key ", query);
746  throw( QString( "Database Error executing query." ));
747  }
748 
749  while (query.next())
750  pList->Settings().insert( query.value(0).toString(), query.value(1) );
751 
752  return pList;
753 }
754 
756 //
758 
759 bool V2Myth::PutSetting( const QString &sHostName,
760  const QString &sKey,
761  const QString &sValue )
762 {
763  QString hostName = sHostName;
764 
765  if (hostName == "_GLOBAL_")
766  hostName = "";
767 
768  if (!sKey.isEmpty())
769  {
770  return gCoreContext->SaveSettingOnHost( sKey, sValue, hostName );
771  }
772 
773  throw ( QString( "Key Required" ));
774 }
775 
777 //
779 
780 bool V2Myth::DeleteSetting( const QString &sHostName,
781  const QString &sKey)
782 {
783  QString hostName = sHostName;
784 
785  if (hostName == "_GLOBAL_")
786  hostName = "";
787 
788  if (!sKey.isEmpty())
789  {
790  return gCoreContext->GetDB()->ClearSettingOnHost( sKey, hostName );
791  }
792 
793  throw ( QString( "Key Required" ));
794 }
795 
796 
798 //
800 
801 bool V2Myth::TestDBSettings( const QString &sHostName,
802  const QString &sUserName,
803  const QString &sPassword,
804  const QString &sDBName,
805  int dbPort)
806 {
807  bool bResult = false;
808 
809  QString db("mythconverg");
810  int port = 3306;
811 
812  if (!sDBName.isEmpty())
813  db = sDBName;
814 
815  if (dbPort != 0)
816  port = dbPort;
817 
818  bResult = TestDatabase(sHostName, sUserName, sPassword, db, port);
819 
820  return bResult;
821 }
822 
824 //
826 
827 bool V2Myth::SendMessage( const QString &sMessage,
828  const QString &sAddress,
829  int udpPort,
830  int Timeout)
831 {
832  bool bResult = false;
833 
834  if (sMessage.isEmpty())
835  return bResult;
836 
837  if (Timeout < 0 || Timeout > 999)
838  Timeout = 0;
839 
840  QString xmlMessage =
841  "<mythmessage version=\"1\">\n"
842  " <text>" + sMessage + "</text>\n"
843  " <timeout>" + QString::number(Timeout) + "</timeout>\n"
844  "</mythmessage>";
845 
846  QHostAddress address = QHostAddress::Broadcast;
847  unsigned short port = 6948;
848 
849  if (!sAddress.isEmpty())
850  address.setAddress(sAddress);
851 
852  if (udpPort != 0)
853  port = udpPort;
854 
855  auto *sock = new QUdpSocket();
856  QByteArray utf8 = xmlMessage.toUtf8();
857  int size = utf8.length();
858 
859  if (sock->writeDatagram(utf8.constData(), size, address, port) < 0)
860  {
861  LOG(VB_GENERAL, LOG_ERR,
862  QString("Failed to send UDP/XML packet (Message: %1 "
863  "Address: %2 Port: %3")
864  .arg(sMessage, sAddress, QString::number(port)));
865  }
866  else
867  {
868  LOG(VB_GENERAL, LOG_DEBUG,
869  QString("UDP/XML packet sent! (Message: %1 Address: %2 Port: %3")
870  .arg(sMessage,
871  address.toString().toLocal8Bit(),
872  QString::number(port)));
873  bResult = true;
874  }
875 
876  sock->deleteLater();
877 
878  return bResult;
879 }
880 
881 bool V2Myth::SendNotification( bool bError,
882  const QString &Type,
883  const QString &sMessage,
884  const QString &sOrigin,
885  const QString &sDescription,
886  const QString &sImage,
887  const QString &sExtra,
888  const QString &sProgressText,
889  float fProgress,
890  int Timeout,
891  bool bFullscreen,
892  uint Visibility,
893  uint Priority,
894  const QString &sAddress,
895  int udpPort )
896 {
897  bool bResult = false;
898 
899  if (sMessage.isEmpty())
900  return bResult;
901 
902  if (Timeout < 0 || Timeout > 999)
903  Timeout = -1;
904 
905  QString xmlMessage =
906  "<mythnotification version=\"1\">\n"
907  " <text>" + sMessage + "</text>\n"
908  " <origin>" + (sOrigin.isNull() ? tr("MythServices") : sOrigin) + "</origin>\n"
909  " <description>" + sDescription + "</description>\n"
910  " <timeout>" + QString::number(Timeout) + "</timeout>\n"
911  " <image>" + sImage + "</image>\n"
912  " <extra>" + sExtra + "</extra>\n"
913  " <progress_text>" + sProgressText + "</progress_text>\n"
914  " <progress>" + QString::number(fProgress) + "</progress>\n"
915  " <fullscreen>" + (bFullscreen ? "true" : "false") + "</fullscreen>\n"
916  " <visibility>" + QString::number(Visibility) + "</visibility>\n"
917  " <priority>" + QString::number(Priority) + "</priority>\n"
918  " <type>" + (bError ? "error" : Type) + "</type>\n"
919  "</mythnotification>";
920 
921  QHostAddress address = QHostAddress::Broadcast;
922  unsigned short port = 6948;
923 
924  if (!sAddress.isEmpty())
925  address.setAddress(sAddress);
926 
927  if (udpPort != 0)
928  port = udpPort;
929 
930  auto *sock = new QUdpSocket();
931  QByteArray utf8 = xmlMessage.toUtf8();
932  int size = utf8.length();
933 
934  if (sock->writeDatagram(utf8.constData(), size, address, port) < 0)
935  {
936  LOG(VB_GENERAL, LOG_ERR,
937  QString("Failed to send UDP/XML packet (Notification: %1 "
938  "Address: %2 Port: %3")
939  .arg(sMessage, sAddress, QString::number(port)));
940  }
941  else
942  {
943  LOG(VB_GENERAL, LOG_DEBUG,
944  QString("UDP/XML packet sent! (Notification: %1 Address: %2 Port: %3")
945  .arg(sMessage,
946  address.toString().toLocal8Bit(), QString::number(port)));
947  bResult = true;
948  }
949 
950  sock->deleteLater();
951 
952  return bResult;
953 }
954 
956 //
958 
960 {
961  bool bResult = false;
962 
963  DBUtil dbutil;
965  QString filename;
966 
967  LOG(VB_GENERAL, LOG_NOTICE, "Performing API invoked DB Backup.");
968 
969  status = DBUtil::BackupDB(filename);
970 
971  if (status == kDB_Backup_Completed)
972  {
973  LOG(VB_GENERAL, LOG_NOTICE, "Database backup succeeded.");
974  bResult = true;
975  }
976  else
977  LOG(VB_GENERAL, LOG_ERR, "Database backup failed.");
978 
979  return bResult;
980 }
981 
983 //
985 
986 bool V2Myth::CheckDatabase( bool repair )
987 {
988  LOG(VB_GENERAL, LOG_NOTICE, "Performing API invoked DB Check.");
989 
990  bool bResult = DBUtil::CheckTables(repair);
991 
992  if (bResult)
993  LOG(VB_GENERAL, LOG_NOTICE, "Database check complete.");
994  else
995  LOG(VB_GENERAL, LOG_ERR, "Database check failed.");
996 
997  return bResult;
998 }
999 
1001 {
1002  auto *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
1003  if (scheduler == nullptr)
1004  return false;
1005  scheduler->DelayShutdown();
1006  LOG(VB_GENERAL, LOG_NOTICE, "Shutdown delayed 5 minutes for external application.");
1007  return true;
1008 }
1009 
1011 //
1013 
1015 {
1017  LOG(VB_GENERAL, LOG_NOTICE, "Profile Submission...");
1018  profile.GenerateUUIDs();
1019  bool bResult = profile.SubmitProfile();
1020  if (bResult)
1021  LOG(VB_GENERAL, LOG_NOTICE, "Profile Submitted.");
1022 
1023  return bResult;
1024 }
1025 
1027 //
1029 
1031 {
1033  LOG(VB_GENERAL, LOG_NOTICE, "Profile Deletion...");
1034  profile.GenerateUUIDs();
1035  bool bResult = profile.DeleteProfile();
1036  if (bResult)
1037  LOG(VB_GENERAL, LOG_NOTICE, "Profile Deleted.");
1038 
1039  return bResult;
1040 }
1041 
1043 //
1045 
1047 {
1048  QString sProfileURL;
1049 
1051  profile.GenerateUUIDs();
1052  sProfileURL = profile.GetProfileURL();
1053  LOG(VB_GENERAL, LOG_NOTICE, QString("ProfileURL: %1").arg(sProfileURL));
1054 
1055  return sProfileURL;
1056 }
1057 
1059 //
1061 
1063 {
1064  QString sProfileUpdate;
1065 
1067  profile.GenerateUUIDs();
1068  QDateTime tUpdated;
1069  tUpdated = profile.GetLastUpdate();
1070  sProfileUpdate = tUpdated.toString(
1071  gCoreContext->GetSetting( "DateFormat", "MM.dd.yyyy"));
1072 
1073  return sProfileUpdate;
1074 }
1075 
1077 //
1079 
1081 {
1082  QString sProfileText;
1083 
1085  sProfileText = HardwareProfile::GetHardwareProfile();
1086 
1087  return sProfileText;
1088 }
1089 
1091 //
1093 
1095 {
1096 
1097  // ----------------------------------------------------------------------
1098  // Create and populate a Configuration object
1099  // ----------------------------------------------------------------------
1100 
1101  auto *pInfo = new V2BackendInfo();
1102  V2BuildInfo *pBuild = pInfo->Build();
1103  V2EnvInfo *pEnv = pInfo->Env();
1104  V2LogInfo *pLog = pInfo->Log();
1105 
1106  pBuild->setVersion ( MYTH_SOURCE_VERSION );
1107  pBuild->setLibX264 ( CONFIG_LIBX264 );
1108  pBuild->setLibDNS_SD ( CONFIG_LIBDNS_SD );
1109  pEnv->setLANG ( qEnvironmentVariable("LANG") );
1110  pEnv->setLCALL ( qEnvironmentVariable("LC_ALL") );
1111  pEnv->setLCCTYPE ( qEnvironmentVariable("LC_CTYPE") );
1112  pEnv->setHOME ( qEnvironmentVariable("HOME") );
1113  // USER for Linux systems, USERNAME for Windows
1114  pEnv->setUSER ( qEnvironmentVariable("USER",
1115  qEnvironmentVariable("USERNAME")) );
1116  pEnv->setMYTHCONFDIR ( qEnvironmentVariable("MYTHCONFDIR") );
1117  auto *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
1118  if (scheduler != nullptr)
1119  pEnv->setSchedulingEnabled(scheduler->QueryScheduling());
1120  pLog->setLogArgs ( logPropagateArgs );
1121  pEnv->setIsDatabaseIgnored(gCoreContext->GetDB()->IsDatabaseIgnored());
1122  pEnv->setDBTimezoneSupport(DBUtil::CheckTimeZoneSupport());
1123  auto nWebOnly = gContext->getWebOnly();
1124  QString webOnly;
1125  switch (nWebOnly) {
1127  webOnly = "NONE";
1128  break;
1130  webOnly = "DBSETUP";
1131  break;
1133  webOnly = "DBTIMEZONE";
1134  break;
1136  webOnly = "WEBONLYPARM";
1137  break;
1139  webOnly = "IPADDRESS";
1140  break;
1142  webOnly = "SCHEMAUPDATE";
1143  break;
1144  }
1145  pEnv->setWebOnlyStartup (webOnly);
1146 
1147  // ----------------------------------------------------------------------
1148  // Return the pointer... caller is responsible to delete it!!!
1149  // ----------------------------------------------------------------------
1150 
1151  return pInfo;
1152 
1153 }
1154 
1156 //
1158 
1159 bool V2Myth::ManageDigestUser( const QString &sAction,
1160  const QString &sUserName,
1161  const QString &sPassword,
1162  const QString &sNewPassword,
1163  const QString &sAdminPassword )
1164 {
1165 
1166  DigestUserActions sessionAction = DIGEST_USER_ADD;
1167 
1168  if (sAction == "Add")
1169  sessionAction = DIGEST_USER_ADD;
1170  else if (sAction == "Remove")
1171  sessionAction = DIGEST_USER_REMOVE;
1172  else if (sAction == "ChangePassword")
1173  sessionAction = DIGEST_USER_CHANGE_PW;
1174  else
1175  {
1176  LOG(VB_GENERAL, LOG_ERR, QString("Action must be Add, Remove or "
1177  "ChangePassword, not '%1'")
1178  .arg(sAction));
1179  return false;
1180  }
1181 
1182  return MythSessionManager::ManageDigestUser(sessionAction, sUserName,
1183  sPassword, sNewPassword,
1184  sAdminPassword);
1185 }
1186 
1188 //
1190 
1191 bool V2Myth::ManageUrlProtection( const QString &sServices,
1192  const QString &sAdminPassword )
1193 {
1194  LOG(VB_GENERAL, LOG_WARNING, QString("ManageUrlProtection is deprecated."
1195  "Protection unavailable in API V2."));
1196 
1197  if (!MythSessionManager::IsValidUser("admin"))
1198  {
1199  LOG(VB_GENERAL, LOG_ERR, QString("Backend has no '%1' user!")
1200  .arg("admin"));
1201  return false;
1202  }
1203 
1204  if (MythSessionManager::CreateDigest("admin", sAdminPassword) !=
1206  {
1207  LOG(VB_GENERAL, LOG_ERR, QString("Incorrect password for user: %1")
1208  .arg("admin"));
1209  return false;
1210  }
1211 
1212  QStringList serviceList = sServices.split(",");
1213 
1214  serviceList.removeDuplicates();
1215 
1216  QStringList protectedURLs;
1217 
1218  if (serviceList.size() == 1 && serviceList.first() == "All")
1219  {
1220  for (const QString& service : KnownServicesV2)
1221  protectedURLs << '/' + service;
1222  }
1223  else if (serviceList.size() == 1 && serviceList.first() == "None")
1224  {
1225  protectedURLs << "Unprotected";
1226  }
1227  else
1228  {
1229  for (const QString& service : std::as_const(serviceList))
1230  {
1231  if (KnownServicesV2.contains(service))
1232  protectedURLs << '/' + service;
1233  else
1234  LOG(VB_GENERAL, LOG_ERR, QString("Invalid service name: '%1'")
1235  .arg(service));
1236  }
1237  }
1238 
1239  if (protectedURLs.isEmpty())
1240  {
1241  LOG(VB_GENERAL, LOG_ERR, "No valid Services were found");
1242  return false;
1243  }
1244 
1245  return gCoreContext->SaveSettingOnHost("HTTP/Protected/Urls",
1246  protectedURLs.join(';'), "");
1247 }
1248 
1249 bool V2Myth::ManageScheduler ( bool Enable, bool Disable )
1250 {
1251  auto *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
1252  if (scheduler == nullptr)
1253  throw QString("Scheduler is null");
1254  // onle and only one of enable and disable must be supplied
1255  if (Enable == Disable)
1256  return false;
1257  if (Enable)
1258  scheduler->EnableScheduling();
1259  else
1260  scheduler->DisableScheduling();
1261  // Stop EIT scanning
1262  QMapIterator<uint,TVRec*> iter(TVRec::s_inputs);
1263  while (iter.hasNext())
1264  {
1265  iter.next();
1266  auto *tvrec = iter.value();
1267  tvrec->EnableActiveScan(Enable);
1268  }
1269  return true;
1270 }
1271 
1272 bool V2Myth::Shutdown ( int Retcode, bool Restart )
1273 {
1274  if (Retcode < 0 || Retcode > 255)
1275  return false;
1276  if (Restart)
1277  {
1278  // Retcode 258 is a special value to signal to mythbackend to restart
1279  // This is designed so that if the execvp fails it will give return code of 2,
1280  // indicating failure and maybe causing the service module to restart.
1281  Retcode = 258;
1282  }
1283  QCoreApplication::exit(Retcode);
1284  return true;
1285 }
Password
static StandardSetting * Password(bool enabled)
Setting for changing password.
Definition: galleryconfig.cpp:245
V2Myth::GetHostName
static QString GetHostName()
Definition: v2myth.cpp:185
Scheduler
Definition: scheduler.h:45
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:813
MythSessionManager::IsValidUser
static bool IsValidUser(const QString &username)
Check if the given user exists but not whether there is a valid session open for them!
Definition: mythsession.cpp:151
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:127
V2Myth::DeleteSetting
static bool DeleteSetting(const QString &HostName, const QString &Key)
Definition: v2myth.cpp:780
hardwareprofile.h
MythSessionManager::GetPasswordDigest
static QString GetPasswordDigest(const QString &username)
Load the password digest for comparison in the HTTP Auth code.
Definition: mythsession.cpp:224
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:84
DatabaseParams::m_dbHostName
QString m_dbHostName
database server
Definition: mythdbparams.h:22
dbutil.h
V2VersionInfo
Definition: v2versionInfo.h:7
backendcontext.h
DIGEST_USER_CHANGE_PW
@ DIGEST_USER_CHANGE_PW
Definition: mythsession.h:13
V2Myth::GetKeys
static QStringList GetKeys()
Definition: v2myth.cpp:232
MythCoreContext::GetScheduler
MythScheduler * GetScheduler(void)
Definition: mythcorecontext.cpp:1905
V2EnvInfo
Definition: v2envInfo.h:16
V2Myth::ProfileUpdated
static QString ProfileUpdated(void)
Definition: v2myth.cpp:1062
MythContext::kWebOnlyNone
@ kWebOnlyNone
Definition: mythcontext.h:60
V2Myth::GetFormatDate
static QString GetFormatDate(const QDateTime &Date, bool ShortDate)
Definition: v2myth.cpp:474
mythdb.h
V2WOLInfo
Definition: v2wolInfo.h:7
getDiskSpace
int64_t getDiskSpace(const QString &file_on_disk, int64_t &total, int64_t &used)
Definition: mythcoreutil.cpp:33
MythDate::as_utc
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
Definition: mythdate.cpp:27
V2Myth::PutSetting
static bool PutSetting(const QString &HostName, const QString &Key, const QString &Value)
Definition: v2myth.cpp:759
V2ConnectionInfo
Definition: v2connectionInfo.h:9
V2Myth::ProfileText
static QString ProfileText(void)
Definition: v2myth.cpp:1080
MythTZ::getTimeZoneID
QString getTimeZoneID(void)
Returns the zoneinfo time zone ID or as much time zone information as possible.
Definition: mythtimezone.cpp:32
V2LogMessageList
Definition: v2logMessageList.h:10
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
Scheduler::DelayShutdown
void DelayShutdown()
Definition: scheduler.cpp:3073
V2LogInfo
Definition: v2logInfo.h:16
V2Myth::DelayShutdown
static bool DelayShutdown(void)
Definition: v2myth.cpp:1000
mythcoreutil.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:204
mythdbcon.h
V2TimeZoneInfo
Definition: v2timeZoneInfo.h:8
TestDatabase
bool TestDatabase(const QString &dbHostName, const QString &dbUserName, QString dbPassword, QString dbName, int dbPort)
Definition: mythdbcon.cpp:41
v2myth.h
mythhttpmetaservice.h
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:619
v2wolInfo.h
MythContext::SaveDatabaseParams
bool SaveDatabaseParams(const DatabaseParams &params, bool force=false)
Definition: mythcontext.cpp:1727
MythContext::kWebOnlyIPAddress
@ kWebOnlyIPAddress
Definition: mythcontext.h:64
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythSessionManager::CreateDigest
static QByteArray CreateDigest(const QString &username, const QString &password)
Generate a digest string.
Definition: mythsession.cpp:536
DBUtil::CheckTables
static bool CheckTables(bool repair=false, const QString &options="QUICK")
Checks database tables.
Definition: dbutil.cpp:275
DatabaseParams::m_dbType
QString m_dbType
database type (MySQL, Postgres, etc.)
Definition: mythdbparams.h:28
GetMythDB
MythDB * GetMythDB(void)
Definition: mythdb.cpp:50
MythDate::kDateTimeShort
@ kDateTimeShort
Default local time.
Definition: mythdate.h:24
scheduler.h
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:14
V2BackendInfo
Definition: v2backendInfo.h:19
DatabaseParams::m_wolReconnect
std::chrono::seconds m_wolReconnect
seconds to wait for reconnect
Definition: mythdbparams.h:35
FillFrontendList
void FillFrontendList(QVariantList &list, QObject *parent, bool OnLine)
Definition: v2serviceUtil.cpp:844
v2versionInfo.h
V2Myth::ManageScheduler
static bool ManageScheduler(bool Enable, bool Disable)
Definition: v2myth.cpp:1249
V2Myth::SetConnectionInfo
static bool SetConnectionInfo(const QString &Host, const QString &UserName, const QString &Password, const QString &Name, int Port, bool DoTest)
Definition: v2myth.cpp:147
MythContext::kWebOnlyDBSetup
@ kWebOnlyDBSetup
Definition: mythcontext.h:61
MythContext::kWebOnlyDBTimezone
@ kWebOnlyDBTimezone
Definition: mythcontext.h:62
V2DatabaseInfo
Definition: v2databaseInfo.h:7
DatabaseParams::m_dbPort
int m_dbPort
database port
Definition: mythdbparams.h:24
mythdate.h
V2BuildInfo
Definition: v2buildInfo.h:16
mythlogging.h
logLevelGetName
QString logLevelGetName(LogLevel_t level)
Map a log level enumerated value back to the name.
Definition: logging.cpp:768
v2serviceUtil.h
MythSessionManager::ManageDigestUser
static bool ManageDigestUser(DigestUserActions action, const QString &username, const QString &password, const QString &newPassword, const QString &adminPassword)
Manage digest user entries.
Definition: mythsession.cpp:550
hardwareprofile.scan.profile
profile
Definition: scan.py:97
DatabaseParams::m_dbHostPing
bool m_dbHostPing
Can we test connectivity using ping?
Definition: mythdbparams.h:23
MYTH_HANDLE
#define MYTH_HANDLE
Definition: v2myth.h:17
HardwareProfile
Definition: hardwareprofile.h:16
V2LabelValue
Definition: v2labelValue.h:13
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:551
MythCoreContext::GetBackendServerIP
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
Definition: mythcorecontext.cpp:1004
V2Myth::GetLogs
static V2LogMessageList * GetLogs(const QString &HostName, const QString &Application, int PID, int TID, const QString &Thread, const QString &Filename, int Line, const QString &Function, const QDateTime &FromTime, const QDateTime &ToTime, const QString &Level, const QString &MsgContains)
Definition: v2myth.cpp:523
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:226
logLevelGet
LogLevel_t logLevelGet(const QString &level)
Map a log level name back to the enumerated value.
Definition: logging.cpp:746
V2Myth::ManageUrlProtection
static bool ManageUrlProtection(const QString &Services, const QString &AdminPassword)
Definition: v2myth.cpp:1191
kDB_Backup_Completed
@ kDB_Backup_Completed
Definition: dbutil.h:13
V2Myth::GetFormatTime
static QString GetFormatTime(const QDateTime &Time)
Definition: v2myth.cpp:500
HardwareProfile::GetHardwareProfile
static QString GetHardwareProfile(void)
Definition: hardwareprofile.cpp:263
MythDate::kAutoYear
@ kAutoYear
Add year only if different from current year.
Definition: mythdate.h:28
DigestUserActions
DigestUserActions
Definition: mythsession.h:10
MythCoreContext::GetDB
MythDB * GetDB(void)
Definition: mythcorecontext.cpp:1753
MythDate::kDateShort
@ kDateShort
Default local time.
Definition: mythdate.h:20
DBUtil
Aggregates database and DBMS utility functions.
Definition: dbutil.h:30
V2Myth::GetFormatDateTime
static QString GetFormatDateTime(const QDateTime &DateTime, bool ShortDate)
Definition: v2myth.cpp:487
KnownServicesV2
const QStringList KnownServicesV2
Definition: v2serviceUtil.h:36
DBUtil::BackupDB
static MythDBBackupStatus BackupDB(QString &filename, bool disableRotation=false)
Requests a backup of the database.
Definition: dbutil.cpp:186
V2StorageGroupDirList
Definition: v2storageGroupDirList.h:9
DBUtil::CheckTimeZoneSupport
static bool CheckTimeZoneSupport(void)
Check if MySQL has working timz zone support.
Definition: dbutil.cpp:863
storagegroup.h
DatabaseParams::m_dbPassword
QString m_dbPassword
DB password.
Definition: mythdbparams.h:26
PID
Contains Packet Identifier numeric values.
Definition: mpegtables.h:206
DatabaseParams::m_wolRetry
int m_wolRetry
times to retry to reconnect
Definition: mythdbparams.h:36
v2databaseInfo.h
DatabaseParams::m_dbName
QString m_dbName
database name
Definition: mythdbparams.h:27
MSqlQuery::isConnected
bool isConnected(void) const
Only updated once during object creation.
Definition: mythdbcon.h:137
MythContext::kWebOnlySchemaUpdate
@ kWebOnlySchemaUpdate
Definition: mythcontext.h:65
uint
unsigned int uint
Definition: compat.h:81
MythDBBackupStatus
MythDBBackupStatus
Definition: dbutil.h:9
DIGEST_USER_REMOVE
@ DIGEST_USER_REMOVE
Definition: mythsession.h:12
V2Myth::BackupDatabase
static bool BackupDatabase(void)
Definition: v2myth.cpp:959
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythHTTPService
Definition: mythhttpservice.h:19
MythContext::getWebOnly
WebOnlyStartup getWebOnly(void)
Definition: mythcontext.h:69
V2Myth::GetDirListing
static QStringList GetDirListing(const QString &DirName)
Definition: v2myth.cpp:266
MythDate::fromString
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
Definition: mythdate.cpp:34
V2Myth::GetFrontends
static V2FrontendList * GetFrontends(bool OnLine)
Definition: v2myth.cpp:656
MythDate::kSimplify
@ kSimplify
Do Today/Yesterday/Tomorrow transform.
Definition: mythdate.h:26
V2Myth::GetSetting
static QString GetSetting(const QString &HostName, const QString &Key, const QString &Default)
Definition: v2myth.cpp:669
V2Myth::AddStorageGroupDir
static bool AddStorageGroupDir(const QString &GroupName, const QString &DirName, const QString &HostName)
Definition: v2myth.cpp:356
MythTZ::calc_utc_offset
int calc_utc_offset(void)
Definition: mythtimezone.cpp:20
MythHTTPService::Name
QString & Name()
Definition: mythhttpservice.cpp:240
V2Myth::GetConnectionInfo
static V2ConnectionInfo * GetConnectionInfo(const QString &Pin)
Definition: v2myth.cpp:67
V2Myth::ParseISODateString
static QDateTime ParseISODateString(const QString &DateTime)
Definition: v2myth.cpp:509
V2Myth::GetStorageGroupDirs
static V2StorageGroupDirList * GetStorageGroupDirs(const QString &GroupName, const QString &HostName)
Definition: v2myth.cpp:276
V2LogMessage
Definition: v2logMessage.h:13
V2Myth::GetHosts
static QStringList GetHosts()
Definition: v2myth.cpp:197
V2StorageGroupDir
Definition: v2storageGroupDir.h:6
DatabaseParams::m_wolCommand
QString m_wolCommand
command to use for wake-on-lan
Definition: mythdbparams.h:37
Name
Definition: channelsettings.cpp:71
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:926
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:889
V2Myth::CheckDatabase
static bool CheckDatabase(bool Repair)
Definition: v2myth.cpp:986
MythDate::ISODate
@ ISODate
Default UTC.
Definition: mythdate.h:17
DatabaseParams::m_dbUserName
QString m_dbUserName
DB user name.
Definition: mythdbparams.h:25
V2Myth::Shutdown
static bool Shutdown(int Retcode, bool Restart)
Definition: v2myth.cpp:1272
V2SettingList
Definition: v2settingList.h:16
V2Myth::ProfileSubmit
static bool ProfileSubmit(void)
Definition: v2myth.cpp:1014
tv_rec.h
V2Myth::GetBackendInfo
static V2BackendInfo * GetBackendInfo(void)
Definition: v2myth.cpp:1094
V2Myth::TestDBSettings
static bool TestDBSettings(const QString &HostName, const QString &UserName, const QString &Password, const QString &DBName, int dbPort)
Definition: v2myth.cpp:801
MythDate::kDateFull
@ kDateFull
Default local time.
Definition: mythdate.h:19
V2Myth::RegisterCustomTypes
static void RegisterCustomTypes()
V2FrontendList
Definition: v2frontendList.h:18
V2Myth::ProfileURL
static QString ProfileURL(void)
Definition: v2myth.cpp:1046
MythContext::kWebOnlyWebOnlyParm
@ kWebOnlyWebOnlyParm
Definition: mythcontext.h:63
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:838
DIGEST_USER_ADD
@ DIGEST_USER_ADD
Definition: mythsession.h:11
logPropagateArgs
QString logPropagateArgs
Definition: logging.cpp:82
V2Myth::ManageDigestUser
static bool ManageDigestUser(const QString &Action, const QString &UserName, const QString &Password, const QString &NewPassword, const QString &AdminPassword)
Definition: v2myth.cpp:1159
kDB_Backup_Unknown
@ kDB_Backup_Unknown
Definition: dbutil.h:11
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
MythDate::kDateTimeFull
@ kDateTimeFull
Default local time.
Definition: mythdate.h:23
Q_GLOBAL_STATIC_WITH_ARGS
Q_GLOBAL_STATIC_WITH_ARGS(MythHTTPMetaService, s_service,(MYTH_HANDLE, V2Myth::staticMetaObject, &V2Myth::RegisterCustomTypes)) void V2Myth
Definition: v2myth.cpp:33
MythDate::kTime
@ kTime
Default local time.
Definition: mythdate.h:22
DatabaseParams::m_wolEnabled
bool m_wolEnabled
true if wake-on-lan params are used
Definition: mythdbparams.h:34
build_compdb.filename
filename
Definition: build_compdb.py:21
V2Myth::SendMessage
static bool SendMessage(const QString &Message, const QString &Address, int udpPort, int Timeout)
Definition: v2myth.cpp:827
DatabaseParams::m_localHostName
QString m_localHostName
name used for loading/saving settings
Definition: mythdbparams.h:31
V2Myth::SendNotification
static bool SendNotification(bool Error, const QString &Type, const QString &Message, const QString &Origin, const QString &Description, const QString &Image, const QString &Extra, const QString &ProgressText, float Progress, int Timeout, bool Fullscreen, uint Visibility, uint Priority, const QString &Address, int udpPort)
Definition: v2myth.cpp:881
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:891
gContext
MythContext * gContext
This global variable contains the MythContext instance for the application.
Definition: mythcontext.cpp:64
Priority
Definition: channelsettings.cpp:216
mythtimezone.h
MythHTTPMetaService
Definition: mythhttpmetaservice.h:10
V2Myth::RemoveStorageGroupDir
static bool RemoveStorageGroupDir(const QString &GroupName, const QString &DirName, const QString &HostName)
Definition: v2myth.cpp:418
V2Myth::V2Myth
V2Myth()
Definition: v2myth.cpp:58
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:898
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:838
V2Myth::GetTimeZone
static V2TimeZoneInfo * GetTimeZone()
Definition: v2myth.cpp:459
TVRec::s_inputs
static QMap< uint, TVRec * > s_inputs
Definition: tv_rec.h:433
V2Myth::ProfileDelete
static bool ProfileDelete(void)
Definition: v2myth.cpp:1030
V2Myth::GetSettingList
static V2SettingList * GetSettingList(const QString &HostName)
Definition: v2myth.cpp:707