MythTV  master
mythdbparams.cpp
Go to the documentation of this file.
1 #include "mythdbparams.h"
2 #include "mythlogging.h"
3 
10 {
11  m_dbHostName = "localhost";
12  m_dbHostPing = true;
13  m_dbPort = 3306;
14  m_dbUserName = "mythtv";
15  m_dbPassword = "mythtv";
16  m_dbName = "mythconverg";
17  m_dbType = "QMYSQL";
18 
19  m_localEnabled = false;
20  m_localHostName = "my-unique-identifier-goes-here";
21 
22  m_wolEnabled = false;
23  m_wolReconnect = 0s;
24  m_wolRetry = 5;
25  m_wolCommand = "echo 'WOLsqlServerCommand not set'";
26 
27  m_forceSave = false;
28 
29  m_verVersion.clear();
30  m_verBranch.clear();
31  m_verProtocol.clear();
32  m_verBinary.clear();
33  m_verSchema.clear();
34 }
35 
36 bool DatabaseParams::IsValid(const QString &source) const
37 {
38  // Print some warnings if things look fishy..
39  QString msg = QString(" is not set in %1").arg(source);
40 
41  if (m_dbHostName.isEmpty())
42  {
43  LOG(VB_GENERAL, LOG_ERR, "DBHostName" + msg);
44  return false;
45  }
46  if (m_dbUserName.isEmpty())
47  {
48  LOG(VB_GENERAL, LOG_ERR, "DBUserName" + msg);
49  return false;
50  }
51  if (m_dbPassword.isEmpty())
52  {
53  LOG(VB_GENERAL, LOG_ERR, "DBPassword" + msg);
54  return false;
55  }
56  if (m_dbName.isEmpty())
57  {
58  LOG(VB_GENERAL, LOG_ERR, "DBName" + msg);
59  return false;
60  }
61 
62  return true;
63 }
64 
66 {
67  return
68  m_dbHostName == other.m_dbHostName &&
69  m_dbHostPing == other.m_dbHostPing &&
70  m_dbPort == other.m_dbPort &&
71  m_dbUserName == other.m_dbUserName &&
72  m_dbPassword == other.m_dbPassword &&
73  m_dbName == other.m_dbName &&
74  m_dbType == other.m_dbType &&
75  m_localEnabled == other.m_localEnabled &&
76  m_wolEnabled == other.m_wolEnabled &&
78  (!m_wolEnabled ||
79  (m_wolReconnect == other.m_wolReconnect &&
80  m_wolRetry == other.m_wolRetry &&
81  m_wolCommand == other.m_wolCommand));
82 }
DatabaseParams::m_dbHostName
QString m_dbHostName
database server
Definition: mythdbparams.h:22
DatabaseParams::m_forceSave
bool m_forceSave
set to true to force a save of the settings file
Definition: mythdbparams.h:40
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
DatabaseParams::m_dbType
QString m_dbType
database type (MySQL, Postgres, etc.)
Definition: mythdbparams.h:28
DatabaseParams::m_verBranch
QString m_verBranch
git branch
Definition: mythdbparams.h:43
DatabaseParams::m_wolReconnect
std::chrono::seconds m_wolReconnect
seconds to wait for reconnect
Definition: mythdbparams.h:35
DatabaseParams::m_dbPort
int m_dbPort
database port
Definition: mythdbparams.h:24
DatabaseParams::m_verVersion
QString m_verVersion
git version string
Definition: mythdbparams.h:42
mythlogging.h
DatabaseParams::m_dbHostPing
bool m_dbHostPing
Can we test connectivity using ping?
Definition: mythdbparams.h:23
DatabaseParams::m_verSchema
QString m_verSchema
core schema version
Definition: mythdbparams.h:46
DatabaseParams::m_dbPassword
QString m_dbPassword
DB password.
Definition: mythdbparams.h:26
DatabaseParams::m_wolRetry
int m_wolRetry
times to retry to reconnect
Definition: mythdbparams.h:36
DatabaseParams::m_dbName
QString m_dbName
database name
Definition: mythdbparams.h:27
DatabaseParams::m_verProtocol
QString m_verProtocol
backend protocol
Definition: mythdbparams.h:44
DatabaseParams::LoadDefaults
void LoadDefaults(void)
Load sensible connection defaults.
Definition: mythdbparams.cpp:9
DatabaseParams::m_wolCommand
QString m_wolCommand
command to use for wake-on-lan
Definition: mythdbparams.h:37
DatabaseParams::m_verBinary
QString m_verBinary
binary library version
Definition: mythdbparams.h:45
DatabaseParams::m_dbUserName
QString m_dbUserName
DB user name.
Definition: mythdbparams.h:25
DatabaseParams::operator==
bool operator==(const DatabaseParams &other) const
Definition: mythdbparams.cpp:65
DatabaseParams::m_localEnabled
bool m_localEnabled
true if localHostName is not default
Definition: mythdbparams.h:30
DatabaseParams::m_wolEnabled
bool m_wolEnabled
true if wake-on-lan params are used
Definition: mythdbparams.h:34
DatabaseParams::m_localHostName
QString m_localHostName
name used for loading/saving settings
Definition: mythdbparams.h:31
DatabaseParams::IsValid
bool IsValid(const QString &source=QString("Unknown")) const
Definition: mythdbparams.cpp:36
mythdbparams.h