1#ifndef MYTHCORECONTEXT_H_
2#define MYTHCORECONTEXT_H_
52 void SetLocalHostname(
const QString &
hostname);
57 bool SafeConnectToMasterServer(
bool blockingClient =
true,
58 bool openEventSocket =
true);
59 bool ConnectToMasterServer(
bool blockingClient =
true,
60 bool openEventSocket =
true);
63 const QString &announcement,
64 bool *proto_mismatch =
nullptr,
66 std::chrono::milliseconds setup_timeout = -1ms);
70 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
71 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
75 bool error_dialog_desired =
false);
77 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
78 QString path = QString(),
79 const QString& storageGroup = QString());
81 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
82 const QString &path = QString());
83 QString GetMasterHostName(
void);
84 QString GetHostName(
void);
85 QString GetFilePrefix(
void);
87 bool IsConnectedToMaster(
void);
88 void SetAsBackend(
bool backend);
89 bool IsBackend(
void)
const;
90 void SetAsFrontend(
bool frontend);
91 bool IsFrontend(
void)
const;
92 bool IsFrontendOnly(
void);
94 bool IsMasterHost(
void);
95 bool IsMasterHost(
const QString &host);
97 static bool BackendIsRunning(
void);
99 bool IsThisBackend(
const QString &addr);
100 bool IsThisHost(
const QString &addr);
101 bool IsThisHost(
const QString &addr,
const QString &host);
103 void BlockShutdown(
void);
104 void AllowShutdown(
void);
105 bool IsBlockingClient(
void)
const;
107 void SetWOLAllowed(
bool allow);
108 bool IsWOLAllowed()
const;
110 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
115 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
116 const QString &
args);
118 void SetGUIObject(QObject *gui);
119 QObject *GetGUIObject(
void);
120 QObject *GetGUIContext(
void);
121 bool HasGUI(
void)
const;
122 bool IsUIThread(
void);
128 bool IsDatabaseIgnored(
void)
const;
130 void SaveSetting(
const QString &key,
int newValue);
131 void SaveSetting(
const QString &key,
const QString &newValue);
132 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
134 template <
typename T>
136 requires (std::chrono::__is_duration<T>::value)
137 { SaveSetting(key,
static_cast<int>(newValue.count())); }
139 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
140 const QString &host);
142 { SaveSetting(key,
static_cast<int>(newValue)); }
145 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
146 int GetNumSetting(
const QString &key,
int defaultval = 0);
147 template <
typename T>
149 requires (std::chrono::__is_duration<T>::value)
150 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
153 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
154 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
155 double& forced_aspect,
double &refresh_rate,
157 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
160 QString GetSettingOnHost(
const QString &key,
const QString &host,
161 const QString &defaultval =
"");
162 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
163 bool defaultval =
false);
164 int GetNumSettingOnHost(
const QString &key,
const QString &host,
167 int defaultval) =
delete;
169 bool defaultval =
false) =
delete;
170 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
171 double defaultval = 0.0);
173 QString GetBackendServerIP(
void);
174 QString GetBackendServerIP(
const QString &host);
175 QString GetBackendServerIP4(
void);
176 QString GetBackendServerIP4(
const QString &host);
177 QString GetBackendServerIP6(
void);
178 QString GetBackendServerIP6(
const QString &host);
179 QString GetMasterServerIP(
void);
180 static int GetMasterServerPort(
void);
181 int GetMasterServerStatusPort(
void);
182 int GetBackendServerPort(
void);
183 int GetBackendServerPort(
const QString &host);
184 static void ClearBackendServerPortCache();
185 int GetBackendStatusPort(
void);
186 int GetBackendStatusPort(
const QString &host);
189 bool GetScopeForAddress(QHostAddress &addr)
const;
190 void SetScopeForAddress(
const QHostAddress &addr);
191 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
192 enum ResolveType : std::int8_t { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
193 QString resolveSettingAddress(
const QString &name,
194 const QString &host = QString(),
195 ResolveType
type = ResolveAny,
196 bool keepscope =
false);
197 static QString resolveAddress(
const QString &host,
198 ResolveType
type = ResolveAny,
199 bool keepscope =
false) ;
200 bool CheckSubnet(
const QAbstractSocket *socket);
201 bool CheckSubnet(
const QHostAddress &peer);
202 bool IsLocalSubnet(
const QHostAddress &peer,
bool log);
205 void ActivateSettingsCache(
bool activate =
true);
206 void OverrideSettingForSession(
const QString &key,
const QString &value);
207 void ClearOverrideSettingForSession(
const QString &key);
211 void InitPower(
bool Create =
true);
212 void InitLocale(
void);
213 void ReInitLocale(
void);
215 QLocale GetQLocale(
void);
216 void SaveLocaleDefaults(
void);
217 QString GetLanguage(
void);
218 QString GetLanguageAndVariant(
void);
219 void ResetLanguage(
void);
220 QString GetAudioLanguage(
void);
221 QString GetAudioLanguageAndVariant(
void);
222 void ResetAudioLanguage(
void);
223 void ResetSockets(
void);
235 template <
class OBJ,
typename SLOT>
237 requires (std::is_member_function_pointer_v<SLOT>)
239 RegisterForPlayback(qobject_cast<QObject*>(sender),
243 void UnregisterForPlayback(QObject *sender);
244 void WantingPlayback(QObject *sender);
245 bool InWantingPlayback(
void);
246 void TVInWantingPlayback(
bool b);
251 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
252 const QString &pluginversion);
258 void SetExiting(
bool exiting =
true);
259 bool IsExiting(
void);
261 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
262 void UnregisterFileForWrite(
const QString &
file);
263 bool IsRegisteredFileForWrite(
const QString &
file);
266 void setTestIntSettings(QMap<QString,int>& overrides);
267 void setTestFloatSettings(QMap<QString,double>& overrides);
268 void setTestStringSettings(QMap<QString,QString>& overrides);
271 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
275 emit TVPlaybackSought();}
309 bool m_dvbv3 {
false};
static TransMythUICheckBoxSetting * IsMasterBackend()
static int ClearSettingsCache(const MythUtilCommandLineParser &)
static int SendEvent(const MythUtilCommandLineParser &cmdline)
static int SendSystemEvent(const MythUtilCommandLineParser &cmdline)
DB connection pool, used by MSqlQuery. Do not use directly.
This class contains the runtime context for MythTV.
void emitTVPlaybackStarted(void)
void TVPlaybackAboutToStart(void)
void SaveDurSetting(const QString &key, T newValue)
void emitTVPlaybackSought(qint64 position)
void emitTVPlaybackStopped(void)
QMap< QString, QString > m_testOverrideStrings
void TVPlaybackSought(qint64 position)
QMap< QString, double > m_testOverrideFloats
void SaveBoolSetting(const QString &key, bool newValue)
bool GetNumSettingOnHost(const QString &key, const QString &host, bool defaultval=false)=delete
void connected(MythSocket *sock) override
static QHash< QString, int > s_serverPortCache
void TVPlaybackAborted(void)
void emitTVPlaybackUnpaused(void)
void TVPlaybackPaused(void)
void TVPlaybackSought(void)
void TVPlaybackStopped(void)
void SetEventSocket(MythSocket *eventSock)
int GetBoolSettingOnHost(const QString &key, const QString &host, int defaultval)=delete
void emitTVPlaybackPaused(void)
void emitTVPlaybackAborted(void)
T GetDurSetting(const QString &key, T defaultval=T::zero())
int GetBoolSetting(const QString &key, int defaultval)=delete
bool GetDVBv3(void) const
void SetDVBv3(bool dvbv3)
void TVPlaybackPlaying(void)
bool GetNumSetting(const QString &key, bool defaultvalue)=delete
void emitTVPlaybackPlaying(void)
void(QObject::*)(void) PlaybackStartCb
QMap< QString, int > m_testOverrideInts
void SetServerSocket(MythSocket *serverSock)
void TVPlaybackUnpaused(void)
void connectionFailed(MythSocket *sock) override
void TVPlaybackStarted(void)
void RegisterForPlayback(OBJ *sender, SLOT method)
This class is used as a container for messages.
Superclass for making an object have a set of listeners.
void dispatch(const MythEvent &event)
Dispatch an event to all listeners.
This is an generic interface to a program scheduler.
We use digest authentication because it protects the password over unprotected networks.
virtual void readyRead(MythSocket *)=0
virtual void connectionClosed(MythSocket *)=0
Class for communcating between myth backends and frontends.
static const iso6937table * d
static int SendMessage(const MythUtilCommandLineParser &cmdline)
void(MythCoreContext::*)(void) CoreWaitSigFn
MBASE_PUBLIC MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static constexpr std::chrono::milliseconds kMythSocketLongTimeout
None log(str msg, int level=LOGDEBUG)