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 
22 // MythBackend
23 #include "backendcontext.h"
24 #include "scheduler.h"
25 #include "v2databaseInfo.h"
26 #include "v2myth.h"
27 #include "v2serviceUtil.h"
28 #include "v2versionInfo.h"
29 #include "v2wolInfo.h"
30 
31 // This will be initialised in a thread safe manner on first use
33  (MYTH_HANDLE, V2Myth::staticMetaObject, &V2Myth::RegisterCustomTypes))
34 
36 {
37  qRegisterMetaType<V2ConnectionInfo*>("V2ConnectionInfo");
38  qRegisterMetaType<V2VersionInfo*>("V2VersionInfo");
39  qRegisterMetaType<V2DatabaseInfo*>("V2DatabaseInfo");
40  qRegisterMetaType<V2WOLInfo*>("V2WOLInfo");
41  qRegisterMetaType<V2StorageGroupDirList*>("V2StorageGroupDirList");
42  qRegisterMetaType<V2StorageGroupDir*>("V2StorageGroupDir");
43  qRegisterMetaType<V2TimeZoneInfo*>("V2TimeZoneInfo");
44  qRegisterMetaType<V2LogMessage*>("V2LogMessage");
45  qRegisterMetaType<V2LogMessageList*>("V2LogMessageList");
46  qRegisterMetaType<V2LabelValue*>("V2LabelValue");
47  qRegisterMetaType<V2Frontend*>("V2Frontend");
48  qRegisterMetaType<V2FrontendList*>("V2FrontendList");
49  qRegisterMetaType<V2SettingList*>("V2SettingList");
50  qRegisterMetaType<V2BackendInfo*>("V2BackendInfo");
51  qRegisterMetaType<V2EnvInfo*>("V2EnvInfo");
52  qRegisterMetaType<V2LogInfo*>("V2LogInfo");
53  qRegisterMetaType<V2BuildInfo*>("V2BuildInfo");
54 }
55 
56 
58  : MythHTTPService(s_service)
59 {
60 }
61 
63 //
65 
67 {
68  QString sSecurityPin = gCoreContext->GetSetting( "SecurityPin", "");
69 
70  if ( sSecurityPin.isEmpty() )
71  throw( QString( "No Security Pin assigned. Run mythtv-setup to set one." ));
72  //SB: UPnPResult_HumanInterventionRequired,
73 
74  if ((sSecurityPin != "0000" ) && ( sPin != sSecurityPin ))
75  throw( QString( "Not Authorized" ));
76  //SB: UPnPResult_ActionNotAuthorized );
77 
78  DatabaseParams params = GetMythDB()->GetDatabaseParams();
79 
80  // ----------------------------------------------------------------------
81  // Check for DBHostName of "localhost" and change to public name or IP
82  // ----------------------------------------------------------------------
83 
84  QString sServerIP = gCoreContext->GetBackendServerIP();
85  //QString sPeerIP = pRequest->GetPeerAddress();
86 
87  if ((params.m_dbHostName.compare("localhost",Qt::CaseInsensitive)==0
88  || params.m_dbHostName == "127.0.0.1"
89  || params.m_dbHostName == "::1")
90  && !sServerIP.isEmpty()) // &&
91  //(sServerIP != sPeerIP ))
92  {
93  params.m_dbHostName = sServerIP;
94  }
95 
96  // If dbHostName is an IPV6 address with scope,
97  // remove the scope. Unescaped % signs are an
98  // xml violation
99  QString dbHostName(params.m_dbHostName);
100  QHostAddress addr;
101  if (addr.setAddress(dbHostName))
102  {
103  addr.setScopeId(QString());
104  dbHostName = addr.toString();
105  }
106  // ----------------------------------------------------------------------
107  // Create and populate a ConnectionInfo object
108  // ----------------------------------------------------------------------
109 
110  auto *pInfo = new V2ConnectionInfo();
111  V2DatabaseInfo *pDatabase = pInfo->Database();
112  V2WOLInfo *pWOL = pInfo->WOL();
113  V2VersionInfo *pVersion = pInfo->Version();
114 
115  pDatabase->setHost ( dbHostName );
116  pDatabase->setPing ( params.m_dbHostPing );
117  pDatabase->setPort ( params.m_dbPort );
118  pDatabase->setUserName ( params.m_dbUserName );
119  pDatabase->setPassword ( params.m_dbPassword );
120  pDatabase->setName ( params.m_dbName );
121  pDatabase->setType ( params.m_dbType );
122  pDatabase->setLocalEnabled ( params.m_localEnabled );
123  pDatabase->setLocalHostName( params.m_localHostName );
124 
125  pWOL->setEnabled ( params.m_wolEnabled );
126  pWOL->setReconnect ( params.m_wolReconnect.count() );
127  pWOL->setRetry ( params.m_wolRetry );
128  pWOL->setCommand ( params.m_wolCommand );
129 
130  pVersion->setVersion ( MYTH_SOURCE_VERSION );
131  pVersion->setBranch ( MYTH_SOURCE_PATH );
132  pVersion->setProtocol ( MYTH_PROTO_VERSION );
133  pVersion->setBinary ( MYTH_BINARY_VERSION );
134  pVersion->setSchema ( MYTH_DATABASE_VERSION );
135 
136  // ----------------------------------------------------------------------
137  // Return the pointer... caller is responsible to delete it!!!
138  // ----------------------------------------------------------------------
139 
140  return pInfo;
141 }
142 
144 //
146 bool V2Myth::SetConnectionInfo(const QString &Host, const QString &UserName, const QString &Password, const QString &Name, int Port, bool DoTest)
147 {
148  bool bResult = false;
149 
150  QString db("mythconverg");
151  int port = 3306;
152 
153  if (!Name.isEmpty())
154  db = Name;
155 
156  if (Port != 0)
157  port = Port;
158 
159  if (DoTest && !TestDatabase(Host, UserName, Password, db, port))
160  throw( QString( "Database test failed. Not saving database connection information." ));
161 
162  DatabaseParams dbparms;
163  dbparms.m_dbName = db;
164  dbparms.m_dbUserName = UserName;
165  dbparms.m_dbPassword = Password;
166  dbparms.m_dbHostName = Host;
167  dbparms.m_dbPort = port;
168 
169  // Just use some sane defaults for these values
170  dbparms.m_wolEnabled = false;
171  dbparms.m_wolReconnect = 1s;
172  dbparms.m_wolRetry = 3;
173  dbparms.m_wolCommand = QString();
174 
175  bResult = gContext->SaveDatabaseParams(dbparms);
176 
177  return bResult;
178 }
179 
181 //
183 
185 {
186  if (!gCoreContext)
187  throw( QString( "No MythCoreContext in GetHostName." ));
188 
189  return gCoreContext->GetHostName();
190 }
191 
193 //
195 
196 QStringList V2Myth::GetHosts( )
197 {
198  MSqlQuery query(MSqlQuery::InitCon());
199 
200  if (!query.isConnected())
201  throw( QString( "Database not open while trying to load list of hosts" ));
202 
203  query.prepare(
204  "SELECT DISTINCTROW hostname "
205  "FROM settings "
206  "WHERE (not isNull( hostname ))");
207 
208  if (!query.exec())
209  {
210  MythDB::DBError("MythAPI::GetHosts()", query);
211 
212  throw( QString( "Database Error executing query." ));
213  }
214 
215  // ----------------------------------------------------------------------
216  // return the results of the query
217  // ----------------------------------------------------------------------
218 
219  QStringList oList;
220 
221  while (query.next())
222  oList.append( query.value(0).toString() );
223 
224  return oList;
225 }
226 
228 //
230 
231 QStringList V2Myth::GetKeys()
232 {
233  MSqlQuery query(MSqlQuery::InitCon());
234 
235  if (!query.isConnected())
236  throw( QString("Database not open while trying to load settings"));
237 
238  query.prepare("SELECT DISTINCTROW value FROM settings;" );
239 
240  if (!query.exec())
241  {
242  MythDB::DBError("MythAPI::GetKeys()", query);
243 
244  throw( QString( "Database Error executing query." ));
245  }
246 
247  // ----------------------------------------------------------------------
248  // return the results of the query
249  // ----------------------------------------------------------------------
250 
251  QStringList oResults;
252 
253  //pResults->setObjectName( "KeyList" );
254 
255  while (query.next())
256  oResults.append( query.value(0).toString() );
257 
258  return oResults;
259 }
260 
262 // DirListing gets a list of subdirectories
264 
265 QStringList V2Myth::GetDirListing ( const QString &DirName)
266 {
267  QDir directory(DirName);
268  return directory.entryList(QDir::AllDirs|QDir::NoDotAndDotDot, QDir::Name);
269 }
270 
271 
273 //
276  const QString &sHostName )
277 {
278  MSqlQuery query(MSqlQuery::InitCon());
279 
280  if (!query.isConnected())
281  throw( QString("Database not open while trying to list "
282  "Storage Group Dirs"));
283 
284  if (!sGroupName.isEmpty() && !sHostName.isEmpty())
285  {
286  query.prepare("SELECT id, groupname, hostname, dirname "
287  "FROM storagegroup "
288  "WHERE groupname = :GROUP AND hostname = :HOST "
289  "ORDER BY groupname, hostname, dirname" );
290  query.bindValue(":HOST", sHostName);
291  query.bindValue(":GROUP", sGroupName);
292  }
293  else if (!sHostName.isEmpty())
294  {
295  query.prepare("SELECT id, groupname, hostname, dirname "
296  "FROM storagegroup "
297  "WHERE hostname = :HOST "
298  "ORDER BY groupname, hostname, dirname" );
299  query.bindValue(":HOST", sHostName);
300  }
301  else if (!sGroupName.isEmpty())
302  {
303  query.prepare("SELECT id, groupname, hostname, dirname "
304  "FROM storagegroup "
305  "WHERE groupname = :GROUP "
306  "ORDER BY groupname, hostname, dirname" );
307  query.bindValue(":GROUP", sGroupName);
308  }
309  else
310  {
311  query.prepare("SELECT id, groupname, hostname, dirname "
312  "FROM storagegroup "
313  "ORDER BY groupname, hostname, dirname" );
314  }
315 
316  if (!query.exec())
317  {
318  MythDB::DBError("MythAPI::GetStorageGroupDirs()", query);
319 
320  throw( QString( "Database Error executing query." ));
321  }
322 
323  // ----------------------------------------------------------------------
324  // return the results of the query plus R/W and size information
325  // ----------------------------------------------------------------------
326 
327  auto* pList = new V2StorageGroupDirList();
328 
329  while (query.next())
330  {
331  V2StorageGroupDir *pStorageGroupDir = pList->AddNewStorageGroupDir();
332  QFileInfo fi(query.value(3).toString());
333  int64_t free = 0;
334  int64_t total = 0;
335  int64_t used = 0;
336 
337  free = getDiskSpace(query.value(3).toString(), total, used);
338 
339  pStorageGroupDir->setId ( query.value(0).toInt() );
340  pStorageGroupDir->setGroupName ( query.value(1).toString() );
341  pStorageGroupDir->setHostName ( query.value(2).toString() );
342  pStorageGroupDir->setDirName ( query.value(3).toString() );
343  pStorageGroupDir->setDirRead ( fi.isReadable() );
344  pStorageGroupDir->setDirWrite ( fi.isWritable() );
345  pStorageGroupDir->setKiBFree ( free );
346  }
347 
348  return pList;
349 }
350 
352 //
354 
355 bool V2Myth::AddStorageGroupDir( const QString &sGroupName,
356  const QString &sDirName,
357  const QString &sHostName )
358 {
359  MSqlQuery query(MSqlQuery::InitCon());
360 
361  if (!query.isConnected())
362  throw( QString("Database not open while trying to add Storage Group "
363  "dir"));
364 
365  if (sGroupName.isEmpty())
366  throw ( QString( "Storage Group Required" ));
367 
368  if (sDirName.isEmpty())
369  throw ( QString( "Directory Name Required" ));
370 
371  if (sHostName.isEmpty())
372  throw ( QString( "HostName Required" ));
373 
374  query.prepare("SELECT COUNT(*) "
375  "FROM storagegroup "
376  "WHERE groupname = :GROUPNAME "
377  "AND dirname = :DIRNAME "
378  "AND hostname = :HOSTNAME;");
379  query.bindValue(":GROUPNAME", sGroupName );
380  query.bindValue(":DIRNAME" , sDirName );
381  query.bindValue(":HOSTNAME" , sHostName );
382  if (!query.exec())
383  {
384  MythDB::DBError("MythAPI::AddStorageGroupDir()", query);
385 
386  throw( QString( "Database Error executing query." ));
387  }
388 
389  if (query.next())
390  {
391  if (query.value(0).toInt() > 0)
392  return false;
393  }
394 
395  query.prepare("INSERT storagegroup "
396  "( groupname, dirname, hostname ) "
397  "VALUES "
398  "( :GROUPNAME, :DIRNAME, :HOSTNAME );");
399  query.bindValue(":GROUPNAME", sGroupName );
400  query.bindValue(":DIRNAME" , sDirName );
401  query.bindValue(":HOSTNAME" , sHostName );
402 
403  if (!query.exec())
404  {
405  MythDB::DBError("MythAPI::AddStorageGroupDir()", query);
406 
407  throw( QString( "Database Error executing query." ));
408  }
409 
410  return true;
411 }
412 
414 //
416 
417 bool V2Myth::RemoveStorageGroupDir( const QString &sGroupName,
418  const QString &sDirName,
419  const QString &sHostName )
420 {
421  MSqlQuery query(MSqlQuery::InitCon());
422 
423  if (!query.isConnected())
424  throw( QString("Database not open while trying to remove Storage "
425  "Group dir"));
426 
427  if (sGroupName.isEmpty())
428  throw ( QString( "Storage Group Required" ));
429 
430  if (sDirName.isEmpty())
431  throw ( QString( "Directory Name Required" ));
432 
433  if (sHostName.isEmpty())
434  throw ( QString( "HostName Required" ));
435 
436  query.prepare("DELETE "
437  "FROM storagegroup "
438  "WHERE groupname = :GROUPNAME "
439  "AND dirname = :DIRNAME "
440  "AND hostname = :HOSTNAME;");
441  query.bindValue(":GROUPNAME", sGroupName );
442  query.bindValue(":DIRNAME" , sDirName );
443  query.bindValue(":HOSTNAME" , sHostName );
444  if (!query.exec())
445  {
446  MythDB::DBError("MythAPI::RemoveStorageGroupDir()", query);
447 
448  throw( QString( "Database Error executing query." ));
449  }
450 
451  return true;
452 }
453 
455 //
457 
459 {
460  auto *pResults = new V2TimeZoneInfo();
461 
462  pResults->setTimeZoneID( MythTZ::getTimeZoneID() );
463  pResults->setUTCOffset( MythTZ::calc_utc_offset() );
464  pResults->setCurrentDateTime( MythDate::current(true) );
465 
466  return pResults;
467 }
468 
470 //
472 
473 QString V2Myth::GetFormatDate(const QDateTime &Date, bool ShortDate)
474 {
476  if (ShortDate)
478 
479  return MythDate::toString(Date, dateFormat);
480 }
481 
483 //
485 
486 QString V2Myth::GetFormatDateTime(const QDateTime &DateTime, bool ShortDate)
487 {
489  if (ShortDate)
491 
492  return MythDate::toString(DateTime, dateFormat);
493 }
494 
496 //
498 
499 QString V2Myth::GetFormatTime(const QDateTime &Time)
500 {
501  return MythDate::toString(Time, MythDate::kTime);
502 }
503 
505 //
507 
508 QDateTime V2Myth::ParseISODateString(const QString& DateTime)
509 {
510  auto dateTime = QDateTime::fromString(DateTime, Qt::ISODate);
511 
512  if (!dateTime.isValid())
513  throw QString( "Unable to parse DateTime" );
514 
515  return dateTime;
516 }
517 
519 //
521 
522 V2LogMessageList* V2Myth::GetLogs( const QString &HostName,
523  const QString &Application,
524  int PID,
525  int TID,
526  const QString &Thread,
527  const QString &Filename,
528  int Line,
529  const QString &Function,
530  const QDateTime &FromTime,
531  const QDateTime &ToTime,
532  const QString &Level,
533  const QString &MsgContains )
534 {
535  auto *pList = new V2LogMessageList();
536 
537  MSqlQuery query(MSqlQuery::InitCon());
538 
539  // Get host name list
540  QString sql = "SELECT DISTINCT host FROM logging ORDER BY host ASC";
541  if (!query.exec(sql))
542  {
543  MythDB::DBError("Retrieving log host names", query);
544  delete pList;
545  throw( QString( "Database Error executing query." ));
546  }
547  while (query.next())
548  {
549  V2LabelValue *pLabelValue = pList->AddNewHostName();
550  QString availableHostName = query.value(0).toString();
551  pLabelValue->setValue ( availableHostName );
552  pLabelValue->setActive ( availableHostName == HostName );
553  pLabelValue->setSelected( availableHostName == HostName );
554  }
555  // Get application list
556  sql = "SELECT DISTINCT application FROM logging ORDER BY application ASC";
557  if (!query.exec(sql))
558  {
559  MythDB::DBError("Retrieving log applications", query);
560  delete pList;
561  throw( QString( "Database Error executing query." ));
562  }
563  while (query.next())
564  {
565  V2LabelValue *pLabelValue = pList->AddNewApplication();
566  QString availableApplication = query.value(0).toString();
567  pLabelValue->setValue ( availableApplication );
568  pLabelValue->setActive ( availableApplication == Application );
569  pLabelValue->setSelected( availableApplication == Application );
570  }
571 
572  if (!HostName.isEmpty() && !Application.isEmpty())
573  {
574  // Get log messages
575  sql = "SELECT host, application, pid, tid, thread, filename, "
576  " line, function, msgtime, level, message "
577  " FROM logging "
578  " WHERE host = COALESCE(:HOSTNAME, host) "
579  " AND application = COALESCE(:APPLICATION, application) "
580  " AND pid = COALESCE(:PID, pid) "
581  " AND tid = COALESCE(:TID, tid) "
582  " AND thread = COALESCE(:THREAD, thread) "
583  " AND filename = COALESCE(:FILENAME, filename) "
584  " AND line = COALESCE(:LINE, line) "
585  " AND function = COALESCE(:FUNCTION, function) "
586  " AND msgtime >= COALESCE(:FROMTIME, msgtime) "
587  " AND msgtime <= COALESCE(:TOTIME, msgtime) "
588  " AND level <= COALESCE(:LEVEL, level) "
589  ;
590  if (!MsgContains.isEmpty())
591  {
592  sql.append(" AND message LIKE :MSGCONTAINS ");
593  }
594  sql.append(" ORDER BY msgtime ASC;");
595 
596 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
597  QVariant ullNull = QVariant(QVariant::ULongLong);
598 #else
599  QVariant ullNull = QVariant(QMetaType(QMetaType::ULongLong));
600 #endif
601  query.prepare(sql);
602 
603  query.bindValue(":HOSTNAME", (HostName.isEmpty()) ? QString() : HostName);
604  query.bindValue(":APPLICATION", (Application.isEmpty()) ? QString() :
605  Application);
606  query.bindValue(":PID", ( PID == 0 ) ? ullNull : (qint64)PID);
607  query.bindValue(":TID", ( TID == 0 ) ? ullNull : (qint64)TID);
608  query.bindValue(":THREAD", (Thread.isEmpty()) ? QString() : Thread);
609  query.bindValue(":FILENAME", (Filename.isEmpty()) ? QString() : Filename);
610  query.bindValue(":LINE", ( Line == 0 ) ? ullNull : (qint64)Line);
611  query.bindValue(":FUNCTION", (Function.isEmpty()) ? QString() : Function);
612  query.bindValue(":FROMTIME", (FromTime.isValid()) ? FromTime : QDateTime());
613  query.bindValue(":TOTIME", (ToTime.isValid()) ? ToTime : QDateTime());
614  query.bindValue(":LEVEL", (Level.isEmpty()) ? ullNull :
615  (qint64)logLevelGet(Level));
616 
617  if (!MsgContains.isEmpty())
618  {
619  query.bindValue(":MSGCONTAINS", "%" + MsgContains + "%" );
620  }
621 
622  if (!query.exec())
623  {
624  MythDB::DBError("Retrieving log messages", query);
625  delete pList;
626  throw( QString( "Database Error executing query." ));
627  }
628 
629  while (query.next())
630  {
631  V2LogMessage *pLogMessage = pList->AddNewLogMessage();
632 
633  pLogMessage->setHostName( query.value(0).toString() );
634  pLogMessage->setApplication( query.value(1).toString() );
635  pLogMessage->setPID( query.value(2).toInt() );
636  pLogMessage->setTID( query.value(3).toInt() );
637  pLogMessage->setThread( query.value(4).toString() );
638  pLogMessage->setFilename( query.value(5).toString() );
639  pLogMessage->setLine( query.value(6).toInt() );
640  pLogMessage->setFunction( query.value(7).toString() );
641  pLogMessage->setTime(MythDate::as_utc(query.value(8).toDateTime()));
642  pLogMessage->setLevel( logLevelGetName(
643  (LogLevel_t)query.value(9).toInt()) );
644  pLogMessage->setMessage( query.value(10).toString() );
645  }
646  }
647 
648  return pList;
649 }
650 
652 //
654 
656 {
657  auto *pList = new V2FrontendList();
658 
659  FillFrontendList(pList->GetFrontends(), pList,
660  OnLine);
661  return pList;
662 }
663 
665 //
667 
668 QString V2Myth::GetSetting( const QString &sHostName,
669  const QString &sKey,
670  const QString &sDefault )
671 {
672  if (sKey.isEmpty())
673  throw( QString("Missing or empty Key (settings.value)") );
674 
675  if (sHostName == "_GLOBAL_")
676  {
677  MSqlQuery query(MSqlQuery::InitCon());
678 
679  query.prepare("SELECT data FROM settings "
680  "WHERE value = :VALUE "
681  "AND (hostname IS NULL)" );
682 
683  query.bindValue(":VALUE", sKey );
684 
685  if (!query.exec())
686  {
687  MythDB::DBError("API Myth/GetSetting ", query);
688  throw( QString( "Database Error executing query." ));
689  }
690 
691  return query.next() ? query.value(0).toString() : sDefault;
692  }
693 
694  QString hostname = sHostName;
695 
696  if (sHostName.isEmpty())
698 
699  return gCoreContext->GetSettingOnHost(sKey, hostname, sDefault);
700 }
701 
703 //
705 
706 V2SettingList* V2Myth::GetSettingList(const QString &sHostName)
707 {
708 
709  MSqlQuery query(MSqlQuery::InitCon());
710 
711  if (!query.isConnected())
712  {
713  throw( QString("Database not open while trying to load settings for host: %1")
714  .arg( sHostName ));
715  }
716 
717  auto *pList = new V2SettingList();
718 
719  pList->setHostName ( sHostName );
720 
721  // ------------------------------------------------------------------
722  // Looking to return all Setting for supplied hostname
723  // ------------------------------------------------------------------
724 
725  if (sHostName.isEmpty())
726  {
727  query.prepare("SELECT value, data FROM settings "
728  "WHERE (hostname IS NULL)" );
729  }
730  else
731  {
732  query.prepare("SELECT value, data FROM settings "
733  "WHERE (hostname = :HOSTNAME)" );
734 
735  query.bindValue(":HOSTNAME", sHostName );
736  }
737 
738  if (!query.exec())
739  {
740  // clean up unused object we created.
741 
742  delete pList;
743 
744  MythDB::DBError("MythAPI::GetSetting() w/o key ", query);
745  throw( QString( "Database Error executing query." ));
746  }
747 
748  while (query.next())
749  pList->Settings().insert( query.value(0).toString(), query.value(1) );
750 
751  return pList;
752 }
753 
755 //
757 
758 bool V2Myth::PutSetting( const QString &sHostName,
759  const QString &sKey,
760  const QString &sValue )
761 {
762  QString hostName = sHostName;
763 
764  if (hostName == "_GLOBAL_")
765  hostName = "";
766 
767  if (!sKey.isEmpty())
768  {
769  return gCoreContext->SaveSettingOnHost( sKey, sValue, hostName );
770  }
771 
772  throw ( QString( "Key Required" ));
773 }
774 
776 //
778 
779 bool V2Myth::DeleteSetting( const QString &sHostName,
780  const QString &sKey)
781 {
782  QString hostName = sHostName;
783 
784  if (hostName == "_GLOBAL_")
785  hostName = "";
786 
787  if (!sKey.isEmpty())
788  {
789  return gCoreContext->GetDB()->ClearSettingOnHost( sKey, hostName );
790  }
791 
792  throw ( QString( "Key Required" ));
793 }
794 
795 
797 //
799 
800 bool V2Myth::TestDBSettings( const QString &sHostName,
801  const QString &sUserName,
802  const QString &sPassword,
803  const QString &sDBName,
804  int dbPort)
805 {
806  bool bResult = false;
807 
808  QString db("mythconverg");
809  int port = 3306;
810 
811  if (!sDBName.isEmpty())
812  db = sDBName;
813 
814  if (dbPort != 0)
815  port = dbPort;
816 
817  bResult = TestDatabase(sHostName, sUserName, sPassword, db, port);
818 
819  return bResult;
820 }
821 
823 //
825 
826 bool V2Myth::SendMessage( const QString &sMessage,
827  const QString &sAddress,
828  int udpPort,
829  int Timeout)
830 {
831  bool bResult = false;
832 
833  if (sMessage.isEmpty())
834  return bResult;
835 
836  if (Timeout < 0 || Timeout > 999)
837  Timeout = 0;
838 
839  QString xmlMessage =
840  "<mythmessage version=\"1\">\n"
841  " <text>" + sMessage + "</text>\n"
842  " <timeout>" + QString::number(Timeout) + "</timeout>\n"
843  "</mythmessage>";
844 
845  QHostAddress address = QHostAddress::Broadcast;
846  unsigned short port = 6948;
847 
848  if (!sAddress.isEmpty())
849  address.setAddress(sAddress);
850 
851  if (udpPort != 0)
852  port = udpPort;
853 
854  auto *sock = new QUdpSocket();
855  QByteArray utf8 = xmlMessage.toUtf8();
856  int size = utf8.length();
857 
858  if (sock->writeDatagram(utf8.constData(), size, address, port) < 0)
859  {
860  LOG(VB_GENERAL, LOG_ERR,
861  QString("Failed to send UDP/XML packet (Message: %1 "
862  "Address: %2 Port: %3")
863  .arg(sMessage, sAddress, QString::number(port)));
864  }
865  else
866  {
867  LOG(VB_GENERAL, LOG_DEBUG,
868  QString("UDP/XML packet sent! (Message: %1 Address: %2 Port: %3")
869  .arg(sMessage,
870  address.toString().toLocal8Bit(),
871  QString::number(port)));
872  bResult = true;
873  }
874 
875  sock->deleteLater();
876 
877  return bResult;
878 }
879 
880 bool V2Myth::SendNotification( bool bError,
881  const QString &Type,
882  const QString &sMessage,
883  const QString &sOrigin,
884  const QString &sDescription,
885  const QString &sImage,
886  const QString &sExtra,
887  const QString &sProgressText,
888  float fProgress,
889  int Timeout,
890  bool bFullscreen,
891  uint Visibility,
892  uint Priority,
893  const QString &sAddress,
894  int udpPort )
895 {
896  bool bResult = false;
897 
898  if (sMessage.isEmpty())
899  return bResult;
900 
901  if (Timeout < 0 || Timeout > 999)
902  Timeout = -1;
903 
904  QString xmlMessage =
905  "<mythnotification version=\"1\">\n"
906  " <text>" + sMessage + "</text>\n"
907  " <origin>" + (sOrigin.isNull() ? tr("MythServices") : sOrigin) + "</origin>\n"
908  " <description>" + sDescription + "</description>\n"
909  " <timeout>" + QString::number(Timeout) + "</timeout>\n"
910  " <image>" + sImage + "</image>\n"
911  " <extra>" + sExtra + "</extra>\n"
912  " <progress_text>" + sProgressText + "</progress_text>\n"
913  " <progress>" + QString::number(fProgress) + "</progress>\n"
914  " <fullscreen>" + (bFullscreen ? "true" : "false") + "</fullscreen>\n"
915  " <visibility>" + QString::number(Visibility) + "</visibility>\n"
916  " <priority>" + QString::number(Priority) + "</priority>\n"
917  " <type>" + (bError ? "error" : Type) + "</type>\n"
918  "</mythnotification>";
919 
920  QHostAddress address = QHostAddress::Broadcast;
921  unsigned short port = 6948;
922 
923  if (!sAddress.isEmpty())
924  address.setAddress(sAddress);
925 
926  if (udpPort != 0)
927  port = udpPort;
928 
929  auto *sock = new QUdpSocket();
930  QByteArray utf8 = xmlMessage.toUtf8();
931  int size = utf8.length();
932 
933  if (sock->writeDatagram(utf8.constData(), size, address, port) < 0)
934  {
935  LOG(VB_GENERAL, LOG_ERR,
936  QString("Failed to send UDP/XML packet (Notification: %1 "
937  "Address: %2 Port: %3")
938  .arg(sMessage, sAddress, QString::number(port)));
939  }
940  else
941  {
942  LOG(VB_GENERAL, LOG_DEBUG,
943  QString("UDP/XML packet sent! (Notification: %1 Address: %2 Port: %3")
944  .arg(sMessage,
945  address.toString().toLocal8Bit(), QString::number(port)));
946  bResult = true;
947  }
948 
949  sock->deleteLater();
950 
951  return bResult;
952 }
953 
955 //
957 
959 {
960  bool bResult = false;
961 
962  DBUtil dbutil;
964  QString filename;
965 
966  LOG(VB_GENERAL, LOG_NOTICE, "Performing API invoked DB Backup.");
967 
968  status = DBUtil::BackupDB(filename);
969 
970  if (status == kDB_Backup_Completed)
971  {
972  LOG(VB_GENERAL, LOG_NOTICE, "Database backup succeeded.");
973  bResult = true;
974  }
975  else
976  LOG(VB_GENERAL, LOG_ERR, "Database backup failed.");
977 
978  return bResult;
979 }
980 
982 //
984 
985 bool V2Myth::CheckDatabase( bool repair )
986 {
987  LOG(VB_GENERAL, LOG_NOTICE, "Performing API invoked DB Check.");
988 
989  bool bResult = DBUtil::CheckTables(repair);
990 
991  if (bResult)
992  LOG(VB_GENERAL, LOG_NOTICE, "Database check complete.");
993  else
994  LOG(VB_GENERAL, LOG_ERR, "Database check failed.");
995 
996  return bResult;
997 }
998 
1000 {
1001  auto *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
1002  if (scheduler == nullptr)
1003  return false;
1004  scheduler->DelayShutdown();
1005  LOG(VB_GENERAL, LOG_NOTICE, "Shutdown delayed 5 minutes for external application.");
1006  return true;
1007 }
1008 
1010 //
1012 
1014 {
1016  LOG(VB_GENERAL, LOG_NOTICE, "Profile Submission...");
1017  profile.GenerateUUIDs();
1018  bool bResult = profile.SubmitProfile();
1019  if (bResult)
1020  LOG(VB_GENERAL, LOG_NOTICE, "Profile Submitted.");
1021 
1022  return bResult;
1023 }
1024 
1026 //
1028 
1030 {
1032  LOG(VB_GENERAL, LOG_NOTICE, "Profile Deletion...");
1033  profile.GenerateUUIDs();
1034  bool bResult = profile.DeleteProfile();
1035  if (bResult)
1036  LOG(VB_GENERAL, LOG_NOTICE, "Profile Deleted.");
1037 
1038  return bResult;
1039 }
1040 
1042 //
1044 
1046 {
1047  QString sProfileURL;
1048 
1050  profile.GenerateUUIDs();
1051  sProfileURL = profile.GetProfileURL();
1052  LOG(VB_GENERAL, LOG_NOTICE, QString("ProfileURL: %1").arg(sProfileURL));
1053 
1054  return sProfileURL;
1055 }
1056 
1058 //
1060 
1062 {
1063  QString sProfileUpdate;
1064 
1066  profile.GenerateUUIDs();
1067  QDateTime tUpdated;
1068  tUpdated = profile.GetLastUpdate();
1069  sProfileUpdate = tUpdated.toString(
1070  gCoreContext->GetSetting( "DateFormat", "MM.dd.yyyy"));
1071 
1072  return sProfileUpdate;
1073 }
1074 
1076 //
1078 
1080 {
1081  QString sProfileText;
1082 
1084  sProfileText = HardwareProfile::GetHardwareProfile();
1085 
1086  return sProfileText;
1087 }
1088 
1090 //
1092 
1094 {
1095 
1096  // ----------------------------------------------------------------------
1097  // Create and populate a Configuration object
1098  // ----------------------------------------------------------------------
1099 
1100  auto *pInfo = new V2BackendInfo();
1101  V2BuildInfo *pBuild = pInfo->Build();
1102  V2EnvInfo *pEnv = pInfo->Env();
1103  V2LogInfo *pLog = pInfo->Log();
1104 
1105  pBuild->setVersion ( MYTH_SOURCE_VERSION );
1106  pBuild->setLibX264 ( CONFIG_LIBX264 );
1107  pBuild->setLibDNS_SD ( CONFIG_LIBDNS_SD );
1108  pEnv->setLANG ( qEnvironmentVariable("LANG") );
1109  pEnv->setLCALL ( qEnvironmentVariable("LC_ALL") );
1110  pEnv->setLCCTYPE ( qEnvironmentVariable("LC_CTYPE") );
1111  pEnv->setHOME ( qEnvironmentVariable("HOME") );
1112  // USER for Linux systems, USERNAME for Windows
1113  pEnv->setUSER ( qEnvironmentVariable("USER",
1114  qEnvironmentVariable("USERNAME")) );
1115  pEnv->setMYTHCONFDIR ( qEnvironmentVariable("MYTHCONFDIR") );
1116  // This needs to be first assigned to a new QString because setLogArgs
1117  // uses a std_move which clears out the source variable while setting.
1118  QString logArgs = logPropagateArgs;
1119  pLog->setLogArgs ( logArgs );
1120 
1121  // ----------------------------------------------------------------------
1122  // Return the pointer... caller is responsible to delete it!!!
1123  // ----------------------------------------------------------------------
1124 
1125  return pInfo;
1126 
1127 }
1128 
1130 //
1132 
1133 bool V2Myth::ManageDigestUser( const QString &sAction,
1134  const QString &sUserName,
1135  const QString &sPassword,
1136  const QString &sNewPassword,
1137  const QString &sAdminPassword )
1138 {
1139 
1140  DigestUserActions sessionAction = DIGEST_USER_ADD;
1141 
1142  if (sAction == "Add")
1143  sessionAction = DIGEST_USER_ADD;
1144  else if (sAction == "Remove")
1145  sessionAction = DIGEST_USER_REMOVE;
1146  else if (sAction == "ChangePassword")
1147  sessionAction = DIGEST_USER_CHANGE_PW;
1148  else
1149  {
1150  LOG(VB_GENERAL, LOG_ERR, QString("Action must be Add, Remove or "
1151  "ChangePassword, not '%1'")
1152  .arg(sAction));
1153  return false;
1154  }
1155 
1156  return MythSessionManager::ManageDigestUser(sessionAction, sUserName,
1157  sPassword, sNewPassword,
1158  sAdminPassword);
1159 }
1160 
1162 //
1164 
1165 bool V2Myth::ManageUrlProtection( const QString &sServices,
1166  const QString &sAdminPassword )
1167 {
1168  LOG(VB_GENERAL, LOG_WARNING, QString("ManageUrlProtection is deprecated."
1169  "Protection unavailable in API V2."));
1170 
1171  if (!MythSessionManager::IsValidUser("admin"))
1172  {
1173  LOG(VB_GENERAL, LOG_ERR, QString("Backend has no '%1' user!")
1174  .arg("admin"));
1175  return false;
1176  }
1177 
1178  if (MythSessionManager::CreateDigest("admin", sAdminPassword) !=
1180  {
1181  LOG(VB_GENERAL, LOG_ERR, QString("Incorrect password for user: %1")
1182  .arg("admin"));
1183  return false;
1184  }
1185 
1186  QStringList serviceList = sServices.split(",");
1187 
1188  serviceList.removeDuplicates();
1189 
1190  QStringList protectedURLs;
1191 
1192  if (serviceList.size() == 1 && serviceList.first() == "All")
1193  {
1194  for (const QString& service : KnownServicesV2)
1195  protectedURLs << '/' + service;
1196  }
1197  else if (serviceList.size() == 1 && serviceList.first() == "None")
1198  {
1199  protectedURLs << "Unprotected";
1200  }
1201  else
1202  {
1203  for (const QString& service : serviceList)
1204  {
1205  if (KnownServicesV2.contains(service))
1206  protectedURLs << '/' + service;
1207  else
1208  LOG(VB_GENERAL, LOG_ERR, QString("Invalid service name: '%1'")
1209  .arg(service));
1210  }
1211  }
1212 
1213  if (protectedURLs.isEmpty())
1214  {
1215  LOG(VB_GENERAL, LOG_ERR, "No valid Services were found");
1216  return false;
1217  }
1218 
1219  return gCoreContext->SaveSettingOnHost("HTTP/Protected/Urls",
1220  protectedURLs.join(';'), "");
1221 }
Password
static StandardSetting * Password(bool enabled)
Setting for changing password.
Definition: galleryconfig.cpp:245
V2Myth::GetHostName
static QString GetHostName()
Definition: v2myth.cpp:184
Scheduler
Definition: scheduler.h:45
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:807
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:128
V2Myth::DeleteSetting
static bool DeleteSetting(const QString &HostName, const QString &Key)
Definition: v2myth.cpp:779
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:231
MythCoreContext::GetScheduler
MythScheduler * GetScheduler(void)
Definition: mythcorecontext.cpp:1875
V2EnvInfo
Definition: v2envInfo.h:16
V2Myth::ProfileUpdated
static QString ProfileUpdated(void)
Definition: v2myth.cpp:1061
V2Myth::GetFormatDate
static QString GetFormatDate(const QDateTime &Date, bool ShortDate)
Definition: v2myth.cpp:473
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:758
V2ConnectionInfo
Definition: v2connectionInfo.h:9
V2Myth::ProfileText
static QString ProfileText(void)
Definition: v2myth.cpp:1079
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:3077
V2LogInfo
Definition: v2logInfo.h:16
V2Myth::DelayShutdown
static bool DelayShutdown(void)
Definition: v2myth.cpp:999
mythcoreutil.h
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:205
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:39
v2myth.h
mythhttpmetaservice.h
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:608
v2wolInfo.h
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:279
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:820
v2versionInfo.h
V2Myth::SetConnectionInfo
static bool SetConnectionInfo(const QString &Host, const QString &UserName, const QString &Password, const QString &Name, int Port, bool DoTest)
Definition: v2myth.cpp:146
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:818
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:99
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:540
MythCoreContext::GetBackendServerIP
QString GetBackendServerIP(void)
Returns the IP address of the locally defined backend IP.
Definition: mythcorecontext.cpp:1002
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:522
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:227
logLevelGet
LogLevel_t logLevelGet(const QString &level)
Map a log level name back to the enumerated value.
Definition: logging.cpp:796
V2Myth::ManageUrlProtection
static bool ManageUrlProtection(const QString &Services, const QString &AdminPassword)
Definition: v2myth.cpp:1165
kDB_Backup_Completed
@ kDB_Backup_Completed
Definition: dbutil.h:13
V2Myth::GetFormatTime
static QString GetFormatTime(const QDateTime &Time)
Definition: v2myth.cpp:499
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:1757
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:486
KnownServicesV2
const QStringList KnownServicesV2
Definition: v2serviceUtil.h:32
DBUtil::BackupDB
static MythDBBackupStatus BackupDB(QString &filename, bool disableRotation=false)
Requests a backup of the database.
Definition: dbutil.cpp:190
V2StorageGroupDirList
Definition: v2storageGroupDirList.h:9
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:138
uint
unsigned int uint
Definition: compat.h:79
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:958
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:54
MythHTTPService
Definition: mythhttpservice.h:19
V2Myth::GetDirListing
static QStringList GetDirListing(const QString &DirName)
Definition: v2myth.cpp:265
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:655
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:668
V2Myth::AddStorageGroupDir
static bool AddStorageGroupDir(const QString &GroupName, const QString &DirName, const QString &HostName)
Definition: v2myth.cpp:355
MythTZ::calc_utc_offset
int calc_utc_offset(void)
Definition: mythtimezone.cpp:20
MythHTTPService::Name
QString & Name()
Definition: mythhttpservice.cpp:227
V2Myth::GetConnectionInfo
static V2ConnectionInfo * GetConnectionInfo(const QString &Pin)
Definition: v2myth.cpp:66
V2Myth::ParseISODateString
static QDateTime ParseISODateString(const QString &DateTime)
Definition: v2myth.cpp:508
V2Myth::GetStorageGroupDirs
static V2StorageGroupDirList * GetStorageGroupDirs(const QString &GroupName, const QString &HostName)
Definition: v2myth.cpp:275
V2LogMessage
Definition: v2logMessage.h:13
MythContext::SaveDatabaseParams
bool SaveDatabaseParams(const DatabaseParams &params)
Definition: mythcontext.cpp:1699
V2Myth::GetHosts
static QStringList GetHosts()
Definition: v2myth.cpp:196
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:47
MythCoreContext::GetSettingOnHost
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
Definition: mythcorecontext.cpp:924
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:883
V2Myth::CheckDatabase
static bool CheckDatabase(bool Repair)
Definition: v2myth.cpp:985
MythDate::ISODate
@ ISODate
Default UTC.
Definition: mythdate.h:17
DatabaseParams::m_dbUserName
QString m_dbUserName
DB user name.
Definition: mythdbparams.h:25
V2SettingList
Definition: v2settingList.h:16
V2Myth::ProfileSubmit
static bool ProfileSubmit(void)
Definition: v2myth.cpp:1013
V2Myth::GetBackendInfo
static V2BackendInfo * GetBackendInfo(void)
Definition: v2myth.cpp:1093
V2Myth::TestDBSettings
static bool TestDBSettings(const QString &HostName, const QString &UserName, const QString &Password, const QString &DBName, int dbPort)
Definition: v2myth.cpp:800
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:1045
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:836
DIGEST_USER_ADD
@ DIGEST_USER_ADD
Definition: mythsession.h:11
logPropagateArgs
QString logPropagateArgs
Definition: logging.cpp:86
V2Myth::ManageDigestUser
static bool ManageDigestUser(const QString &Action, const QString &UserName, const QString &Password, const QString &NewPassword, const QString &AdminPassword)
Definition: v2myth.cpp:1133
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:32
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:826
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:880
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:889
gContext
MythContext * gContext
This global variable contains the MythContext instance for the application.
Definition: mythcontext.cpp:57
Priority
Definition: channelsettings.cpp:192
mythtimezone.h
MythHTTPMetaService
Definition: mythhttpmetaservice.h:10
V2Myth::RemoveStorageGroupDir
static bool RemoveStorageGroupDir(const QString &GroupName, const QString &DirName, const QString &HostName)
Definition: v2myth.cpp:417
V2Myth::V2Myth
V2Myth()
Definition: v2myth.cpp:57
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:896
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:832
V2Myth::GetTimeZone
static V2TimeZoneInfo * GetTimeZone()
Definition: v2myth.cpp:458
V2Myth::ProfileDelete
static bool ProfileDelete(void)
Definition: v2myth.cpp:1029
V2Myth::GetSettingList
static V2SettingList * GetSettingList(const QString &HostName)
Definition: v2myth.cpp:706