1#ifndef MYTHCORECONTEXT_H_
2#define MYTHCORECONTEXT_H_
52 void SetLocalHostname(
const QString &
hostname);
62 bool SafeConnectToMasterServer(
bool blockingClient =
true,
63 bool openEventSocket =
true);
64 bool ConnectToMasterServer(
bool blockingClient =
true,
65 bool openEventSocket =
true);
68 const QString &announcement,
69 bool *proto_mismatch =
nullptr,
71 std::chrono::milliseconds setup_timeout = -1ms);
75 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
76 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
80 bool error_dialog_desired =
false);
82 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
83 QString path = QString(),
84 const QString& storageGroup = QString());
86 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
87 const QString &path = QString());
88 QString GetMasterHostName(
void);
89 QString GetHostName(
void);
90 QString GetFilePrefix(
void);
92 bool IsConnectedToMaster(
void);
93 void SetAsBackend(
bool backend);
94 bool IsBackend(
void)
const;
95 void SetAsFrontend(
bool frontend);
96 bool IsFrontend(
void)
const;
97 bool IsFrontendOnly(
void);
99 bool IsMasterHost(
void);
100 bool IsMasterHost(
const QString &host);
102 static bool BackendIsRunning(
void);
104 bool IsThisBackend(
const QString &addr);
105 bool IsThisHost(
const QString &addr);
106 bool IsThisHost(
const QString &addr,
const QString &host);
108 void BlockShutdown(
void);
109 void AllowShutdown(
void);
110 bool IsBlockingClient(
void)
const;
112 void SetWOLAllowed(
bool allow);
113 bool IsWOLAllowed()
const;
115 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
120 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
121 const QString &
args);
123 void SetGUIObject(QObject *gui);
124 QObject *GetGUIObject(
void);
125 QObject *GetGUIContext(
void);
126 bool HasGUI(
void)
const;
127 bool IsUIThread(
void);
133 bool IsDatabaseIgnored(
void)
const;
135 void SaveSetting(
const QString &key,
int newValue);
136 void SaveSetting(
const QString &key,
const QString &newValue);
137 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
139 template <
typename T>
141#if HAVE_IS_DURATION_V
142 requires (std::chrono::__is_duration_v<T>)
144 requires (std::chrono::__is_duration<T>::value)
146 { SaveSetting(key,
static_cast<int>(newValue.count())); }
148 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
149 const QString &host);
151 { SaveSetting(key,
static_cast<int>(newValue)); }
154 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
155 int GetNumSetting(
const QString &key,
int defaultval = 0);
156 template <
typename T>
158#if HAVE_IS_DURATION_V
159 requires (std::chrono::__is_duration_v<T>)
161 requires (std::chrono::__is_duration<T>::value)
163 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
166 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
167 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
168 double& forced_aspect,
double &refresh_rate,
170 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
173 QString GetSettingOnHost(
const QString &key,
const QString &host,
174 const QString &defaultval =
"");
175 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
176 bool defaultval =
false);
177 int GetNumSettingOnHost(
const QString &key,
const QString &host,
180 int defaultval) =
delete;
182 bool defaultval =
false) =
delete;
183 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
184 double defaultval = 0.0);
186 QString GetBackendServerIP(
void);
187 QString GetBackendServerIP(
const QString &host);
188 QString GetBackendServerIP4(
void);
189 QString GetBackendServerIP4(
const QString &host);
190 QString GetBackendServerIP6(
void);
191 QString GetBackendServerIP6(
const QString &host);
192 QString GetMasterServerIP(
void);
193 static int GetMasterServerPort(
void);
194 int GetMasterServerStatusPort(
void);
195 int GetBackendServerPort(
void);
196 int GetBackendServerPort(
const QString &host);
197 static void ClearBackendServerPortCache();
198 int GetBackendStatusPort(
void);
199 int GetBackendStatusPort(
const QString &host);
202 bool GetScopeForAddress(QHostAddress &addr)
const;
203 void SetScopeForAddress(
const QHostAddress &addr);
204 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
205 enum ResolveType : std::int8_t { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
206 QString resolveSettingAddress(
const QString &name,
207 const QString &host = QString(),
208 ResolveType
type = ResolveAny,
209 bool keepscope =
false);
210 static QString resolveAddress(
const QString &host,
211 ResolveType
type = ResolveAny,
212 bool keepscope =
false) ;
213 bool CheckSubnet(
const QAbstractSocket *socket);
214 bool CheckSubnet(
const QHostAddress &peer);
215 bool IsLocalSubnet(
const QHostAddress &peer,
bool log);
218 void ActivateSettingsCache(
bool activate =
true);
219 void OverrideSettingForSession(
const QString &key,
const QString &value);
220 void ClearOverrideSettingForSession(
const QString &key);
224 void InitPower(
bool Create =
true);
225 void InitLocale(
void);
226 void ReInitLocale(
void);
228 QLocale GetQLocale(
void);
229 void SaveLocaleDefaults(
void);
230 QString GetLanguage(
void);
231 QString GetLanguageAndVariant(
void);
232 void ResetLanguage(
void);
233 QString GetAudioLanguage(
void);
234 QString GetAudioLanguageAndVariant(
void);
235 void ResetAudioLanguage(
void);
236 void ResetSockets(
void);
248 template <
class OBJ,
typename SLOT>
250 requires (std::is_member_function_pointer_v<SLOT>)
252 RegisterForPlayback(qobject_cast<QObject*>(sender),
256 void UnregisterForPlayback(QObject *sender);
257 void WantingPlayback(QObject *sender);
258 bool InWantingPlayback(
void);
259 void TVInWantingPlayback(
bool b);
264 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
265 const QString &pluginversion);
271 void SetExiting(
bool exiting =
true);
272 bool IsExiting(
void);
274 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
275 void UnregisterFileForWrite(
const QString &
file);
276 bool IsRegisteredFileForWrite(
const QString &
file);
279 void setTestIntSettings(QMap<QString,int>& overrides);
280 void setTestFloatSettings(QMap<QString,double>& overrides);
281 void setTestStringSettings(QMap<QString,QString>& overrides);
284 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
288 emit TVPlaybackSought();}
317 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)