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 = 0;
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 }
QString m_verBinary
binary library version
Definition: mythdbparams.h:44
bool operator==(const DatabaseParams &other) const
QString m_verBranch
git branch
Definition: mythdbparams.h:42
QString m_dbHostName
database server
Definition: mythdbparams.h:21
QString m_localHostName
name used for loading/saving settings
Definition: mythdbparams.h:30
bool m_localEnabled
true if localHostName is not default
Definition: mythdbparams.h:29
bool m_forceSave
set to true to force a save of the settings file
Definition: mythdbparams.h:39
int m_wolReconnect
seconds to wait for reconnect
Definition: mythdbparams.h:34
QString m_dbType
database type (MySQL, Postgres, etc.)
Definition: mythdbparams.h:27
int m_wolRetry
times to retry to reconnect
Definition: mythdbparams.h:35
QString m_verSchema
core schema version
Definition: mythdbparams.h:45
bool m_dbHostPing
Can we test connectivity using ping?
Definition: mythdbparams.h:22
QString m_verVersion
git version string
Definition: mythdbparams.h:41
QString m_dbName
database name
Definition: mythdbparams.h:26
QString m_dbUserName
DB user name.
Definition: mythdbparams.h:24
QString m_verProtocol
backend protocol
Definition: mythdbparams.h:43
QString m_dbPassword
DB password.
Definition: mythdbparams.h:25
bool IsValid(const QString &source=QString("Unknown")) const
int m_dbPort
database port
Definition: mythdbparams.h:23
bool m_wolEnabled
true if wake-on-lan params are used
Definition: mythdbparams.h:33
Structure containing the basic Database parameters.
Definition: mythdbparams.h:9
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void LoadDefaults(void)
Load sensible connection defaults.
Definition: mythdbparams.cpp:9
QString m_wolCommand
command to use for wake-on-lan
Definition: mythdbparams.h:36