-
Notifications
You must be signed in to change notification settings - Fork 341
/
mythcorecontext.h
181 lines (144 loc) · 6.58 KB
/
mythcorecontext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#ifndef MYTHCORECONTEXT_H_
#define MYTHCORECONTEXT_H_
#include <QObject>
#include <QString>
#include "mythdb.h"
#include "mythbaseexp.h"
#include "mythobservable.h"
#include "mythsocket_cb.h"
#include "mythverbose.h"
#include "mythlocale.h"
#define MYTH_APPNAME_MYTHBACKEND "mythbackend"
#define MYTH_APPNAME_MYTHJOBQUEUE "mythjobqueue"
#define MYTH_APPNAME_MYTHFRONTEND "mythfrontend"
#define MYTH_APPNAME_MYTHTV_SETUP "mythtv-setup"
#define MYTH_APPNAME_MYTHFILLDATABASE "mythfilldatabase"
#define MYTH_APPNAME_MYTHCOMMFLAG "mythcommflag"
#define MYTH_APPNAME_MYTHPREVIEWGEN "mythpreviewgen"
#define MYTH_APPNAME_MYTHTRANSCODE "mythtranscode"
#define MYTH_APPNAME_MYTHWELCOME "mythwelcome"
#define MYTH_APPNAME_MYTHSHUTDOWN "mythshutdown"
#define MYTH_APPNAME_MYTHMESSAGE "mythmessage"
#define MYTH_APPNAME_MYTHLCDSERVER "mythlcdserver"
#define MYTH_APPNAME_MYTHAVTEST "mythavtest"
class MDBManager;
class MythCoreContextPrivate;
class MythSocket;
/// These are the database logging priorities used for filterig the logs.
enum LogPriorities
{
LP_EMERG = 0,
LP_ALERT = 1,
LP_CRITICAL = 2,
LP_ERROR = 3,
LP_WARNING = 4,
LP_NOTICE = 5,
LP_INFO = 6,
LP_DEBUG = 7
};
/** \class MythCoreContext
* \brief This class contains the runtime context for MythTV.
*
* This class can be used to query for and set global and host
* settings, and is used to communicate between the frontends
* and backends. It also contains helper functions for theming
* and for getting system defaults, parsing the command line, etc.
* It also contains support for database error printing, and
* database message logging.
*/
class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
{
public:
MythCoreContext(const QString &binversion, QObject *eventHandler);
virtual ~MythCoreContext();
bool Init(void);
void SetLocalHostname(const QString &hostname);
void SetServerSocket(MythSocket *serverSock);
void SetEventSocket(MythSocket *eventSock);
bool ConnectToMasterServer(bool blockingClient = true);
MythSocket *ConnectCommandSocket(const QString &hostname, int port,
const QString &announcement,
bool *proto_mismatch = NULL,
bool gui = true, int maxConnTry = -1,
int setup_timeout = -1);
MythSocket *ConnectEventSocket(const QString &hostname, int port);
bool SetupCommandSocket(MythSocket *serverSock, const QString &announcement,
uint timeout_in_ms, bool &proto_mismatch);
bool CheckProtoVersion(MythSocket *socket,
uint timeout_ms = kMythSocketLongTimeout,
bool error_dialog_desired = false);
QString MythHostAddressAny(void);
QString GenMythURL(QString host = QString(), QString port = QString(),
QString path = QString(), QString storageGroup = QString());
QString GenMythURL(QString host = QString(), int port = 0,
QString path = QString(), QString storageGroup = QString());
QString GetMasterHostPrefix(QString storageGroup = QString());
QString GetMasterHostName(void);
QString GetHostName(void);
QString GetFilePrefix(void);
bool IsConnectedToMaster(void);
void SetBackend(bool backend);
bool IsBackend(void); ///< is this process a backend process
bool IsFrontendOnly(void); ///< is there a frontend, but no backend,
/// running on this host
bool IsMasterHost(void); ///< is this the same host as the master
bool IsMasterBackend(void); ///< is this the actual MBE process
bool BackendIsRunning(void); ///< a backend process is running on this host
void BlockShutdown(void);
void AllowShutdown(void);
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout = false,
bool block = true);
void SetGUIObject(QObject *gui);
QObject *GetGUIObject(void);
bool HasGUI(void);
bool IsUIThread(void);
MythDB *GetDB(void);
MDBManager *GetDBManager(void);
bool IsDatabaseIgnored(void) const;
DatabaseParams GetDatabaseParams(void)
{ return GetDB()->GetDatabaseParams(); }
void SaveSetting(const QString &key, int newValue);
void SaveSetting(const QString &key, const QString &newValue);
QString GetSetting(const QString &key, const QString &defaultval = "");
bool SaveSettingOnHost(const QString &key, const QString &newValue,
const QString &host);
// Convenience setting query methods
int GetNumSetting(const QString &key, int defaultval = 0);
double GetFloatSetting(const QString &key, double defaultval = 0.0);
void GetResolutionSetting(const QString &type, int &width, int &height,
double& forced_aspect, double &refreshrate,
int index=-1);
void GetResolutionSetting(const QString &type, int &width, int &height,
int index=-1);
QString GetSettingOnHost(const QString &key, const QString &host,
const QString &defaultval = "");
int GetNumSettingOnHost(const QString &key, const QString &host,
int defaultval = 0);
double GetFloatSettingOnHost(const QString &key, const QString &host,
double defaultval = 0.0);
void SetSetting(const QString &key, const QString &newValue);
void ClearSettingsCache(const QString &myKey = QString(""));
void ActivateSettingsCache(bool activate = true);
void OverrideSettingForSession(const QString &key, const QString &value);
void dispatch(const MythEvent &event);
void dispatchNow(const MythEvent &event) MDEPRECATED;
void InitLocale(void);
const MythLocale *GetLocale(void);
void SaveLocaleDefaults(void);
QString GetLanguage(void);
QString GetLanguageAndVariant(void);
void ResetLanguage(void);
private:
MythCoreContextPrivate *d;
bool has_ipv6;
void connected(MythSocket *sock) { (void)sock; }
void connectionFailed(MythSocket *sock) { (void)sock; }
void connectionClosed(MythSocket *sock);
void readyRead(MythSocket *sock);
};
/// This global variable contains the MythCoreContext instance for the app
extern MBASE_PUBLIC MythCoreContext *gCoreContext;
/// This global variable is used to makes certain calls to avlib threadsafe.
extern MBASE_PUBLIC QMutex *avcodeclock;
#endif
/* vim: set expandtab tabstop=4 shiftwidth=4: */