1#ifndef MYTHCORECONTEXT_H_
2#define MYTHCORECONTEXT_H_
53 void SetLocalHostname(
const QString &
hostname);
63 bool SafeConnectToMasterServer(
bool blockingClient =
true,
64 bool openEventSocket =
true);
65 bool ConnectToMasterServer(
bool blockingClient =
true,
66 bool openEventSocket =
true);
69 const QString &announcement,
70 bool *proto_mismatch =
nullptr,
72 std::chrono::milliseconds setup_timeout = -1ms);
76 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
77 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
81 bool error_dialog_desired =
false);
83 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
84 QString path = QString(),
85 const QString& storageGroup = QString());
87 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
88 const QString &path = QString());
89 QString GetMasterHostName(
void);
90 QString GetHostName(
void);
91 QString GetFilePrefix(
void);
93 bool IsConnectedToMaster(
void);
94 void SetAsBackend(
bool backend);
95 bool IsBackend(
void)
const;
96 void SetAsFrontend(
bool frontend);
97 bool IsFrontend(
void)
const;
98 bool IsFrontendOnly(
void);
100 bool IsMasterHost(
void);
101 bool IsMasterHost(
const QString &host);
103 static bool BackendIsRunning(
void);
105 bool IsThisBackend(
const QString &addr);
106 bool IsThisHost(
const QString &addr);
107 bool IsThisHost(
const QString &addr,
const QString &host);
109 void BlockShutdown(
void);
110 void AllowShutdown(
void);
111 bool IsBlockingClient(
void)
const;
113 void SetWOLAllowed(
bool allow);
114 bool IsWOLAllowed()
const;
116 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
121 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
122 const QString &
args);
124 void SetGUIObject(QObject *gui);
125 QObject *GetGUIObject(
void);
126 QObject *GetGUIContext(
void);
127 bool HasGUI(
void)
const;
128 bool IsUIThread(
void);
134 bool IsDatabaseIgnored(
void)
const;
136 void SaveSetting(
const QString &key,
int newValue);
137 void SaveSetting(
const QString &key,
const QString &newValue);
138 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
140 template <
typename T>
142#if HAVE_IS_DURATION_V
143 requires (std::chrono::__is_duration_v<T>)
145 requires (std::chrono::__is_duration<T>::value)
147 { SaveSetting(key,
static_cast<int>(newValue.count())); }
149 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
150 const QString &host);
152 { SaveSetting(key,
static_cast<int>(newValue)); }
155 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
156 int GetNumSetting(
const QString &key,
int defaultval = 0);
157 template <
typename T>
159#if HAVE_IS_DURATION_V
160 requires (std::chrono::__is_duration_v<T>)
162 requires (std::chrono::__is_duration<T>::value)
164 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
167 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
168 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
169 double& forced_aspect,
double &refresh_rate,
171 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
174 QString GetSettingOnHost(
const QString &key,
const QString &host,
175 const QString &defaultval =
"");
176 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
177 bool defaultval =
false);
178 int GetNumSettingOnHost(
const QString &key,
const QString &host,
181 int defaultval) =
delete;
183 bool defaultval =
false) =
delete;
184 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
185 double defaultval = 0.0);
187 QString GetBackendServerIP(
void);
188 QString GetBackendServerIP(
const QString &host);
189 QString GetBackendServerIP4(
void);
190 QString GetBackendServerIP4(
const QString &host);
191 QString GetBackendServerIP6(
void);
192 QString GetBackendServerIP6(
const QString &host);
193 QString GetMasterServerIP(
void);
194 static int GetMasterServerPort(
void);
195 int GetMasterServerStatusPort(
void);
196 int GetBackendServerPort(
void);
197 int GetBackendServerPort(
const QString &host);
198 static void ClearBackendServerPortCache();
199 int GetBackendStatusPort(
void);
200 int GetBackendStatusPort(
const QString &host);
203 bool GetScopeForAddress(QHostAddress &addr)
const;
204 void SetScopeForAddress(
const QHostAddress &addr);
205 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
206 enum ResolveType : std::int8_t { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
207 QString resolveSettingAddress(
const QString &name,
208 const QString &host = QString(),
209 ResolveType
type = ResolveAny,
210 bool keepscope =
false);
211 static QString resolveAddress(
const QString &host,
212 ResolveType
type = ResolveAny,
213 bool keepscope =
false) ;
214 bool CheckSubnet(
const QAbstractSocket *socket);
215 bool CheckSubnet(
const QHostAddress &peer);
216 bool IsLocalSubnet(
const QHostAddress &peer,
bool log);
219 void ActivateSettingsCache(
bool activate =
true);
220 void OverrideSettingForSession(
const QString &key,
const QString &value);
221 void ClearOverrideSettingForSession(
const QString &key);
225 void InitPower(
bool Create =
true);
226 void InitLocale(
void);
227 void ReInitLocale(
void);
229 QLocale GetQLocale(
void);
230 void SaveLocaleDefaults(
void);
231 QString GetLanguage(
void);
232 QString GetLanguageAndVariant(
void);
233 void ResetLanguage(
void);
234 QString GetAudioLanguage(
void);
235 QString GetAudioLanguageAndVariant(
void);
236 void ResetAudioLanguage(
void);
237 void ResetSockets(
void);
249 template <
class OBJ,
typename SLOT>
251 requires (std::is_member_function_pointer_v<SLOT>)
253 RegisterForPlayback(qobject_cast<QObject*>(sender),
257 void UnregisterForPlayback(QObject *sender);
258 void WantingPlayback(QObject *sender);
259 bool InWantingPlayback(
void);
260 void TVInWantingPlayback(
bool b);
265 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
266 const QString &pluginversion);
272 void SetExiting(
bool exiting =
true);
273 bool IsExiting(
void);
275 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
276 void UnregisterFileForWrite(
const QString &
file);
277 bool IsRegisteredFileForWrite(
const QString &
file);
280 void setTestIntSettings(QMap<QString,int>& overrides);
281 void setTestFloatSettings(QMap<QString,double>& overrides);
282 void setTestStringSettings(QMap<QString,QString>& overrides);
285 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
289 emit TVPlaybackSought();}
318 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)