1 #ifndef MYTHCORECONTEXT_H_
2 #define MYTHCORECONTEXT_H_
6 #include <QHostAddress>
71 void SetLocalHostname(
const QString &
hostname);
76 bool SafeConnectToMasterServer(
bool blockingClient =
true,
77 bool openEventSocket =
true);
78 bool ConnectToMasterServer(
bool blockingClient =
true,
79 bool openEventSocket =
true);
82 const QString &announcement,
83 bool *proto_mismatch =
nullptr,
85 std::chrono::milliseconds setup_timeout = -1ms);
89 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
90 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
94 bool error_dialog_desired =
false);
96 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
97 QString path = QString(),
98 const QString& storageGroup = QString());
100 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
101 const QString &path = QString());
102 QString GetMasterHostName(
void);
103 QString GetHostName(
void);
104 QString GetFilePrefix(
void);
106 bool IsConnectedToMaster(
void);
107 void SetAsBackend(
bool backend);
108 bool IsBackend(
void)
const;
109 void SetAsFrontend(
bool frontend);
110 bool IsFrontend(
void)
const;
111 bool IsFrontendOnly(
void);
112 bool IsMasterHost(
void);
114 bool IsMasterHost(
const QString &host);
116 static bool BackendIsRunning(
void);
118 bool IsThisBackend(
const QString &addr);
119 bool IsThisHost(
const QString &addr);
120 bool IsThisHost(
const QString &addr,
const QString &host);
122 void BlockShutdown(
void);
123 void AllowShutdown(
void);
124 bool IsBlockingClient(
void)
const;
126 void SetWOLAllowed(
bool allow);
127 bool IsWOLAllowed()
const;
129 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
134 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
135 const QString &
args);
137 void SetGUIObject(QObject *gui);
138 QObject *GetGUIObject(
void);
139 QObject *GetGUIContext(
void);
140 bool HasGUI(
void)
const;
141 bool IsUIThread(
void);
147 bool IsDatabaseIgnored(
void)
const;
149 void SaveSetting(
const QString &key,
int newValue);
150 void SaveSetting(
const QString &key,
const QString &newValue);
151 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
153 template <
typename T>
154 typename std::enable_if_t<std::chrono::__is_duration<T>::value,
void>
156 { SaveSetting(key,
static_cast<int>(newValue.count())); }
158 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
159 const QString &host);
161 { SaveSetting(key,
static_cast<int>(newValue)); }
164 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
165 int GetNumSetting(
const QString &key,
int defaultval = 0);
166 template <
typename T>
167 typename std::enable_if_t<std::chrono::__is_duration<T>::value, T>
169 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
170 int GetBoolSetting(
const QString &key,
int defaultval) =
delete;
171 bool GetNumSetting(
const QString &key,
bool defaultvalue) =
delete;
172 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
173 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
174 double& forced_aspect,
double &refresh_rate,
176 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
179 QString GetSettingOnHost(
const QString &key,
const QString &host,
180 const QString &defaultval =
"");
181 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
182 bool defaultval =
false);
183 int GetNumSettingOnHost(
const QString &key,
const QString &host,
185 int GetBoolSettingOnHost(
const QString &key,
const QString &host,
186 int defaultval) =
delete;
187 bool GetNumSettingOnHost(
const QString &key,
const QString &host,
188 bool defaultval =
false) =
delete;
189 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
190 double defaultval = 0.0);
192 QString GetBackendServerIP(
void);
193 QString GetBackendServerIP(
const QString &host);
194 QString GetBackendServerIP4(
void);
195 QString GetBackendServerIP4(
const QString &host);
196 QString GetBackendServerIP6(
void);
197 QString GetBackendServerIP6(
const QString &host);
198 QString GetMasterServerIP(
void);
199 static int GetMasterServerPort(
void);
200 int GetMasterServerStatusPort(
void);
201 int GetBackendServerPort(
void);
202 int GetBackendServerPort(
const QString &host);
203 static void ClearBackendServerPortCache();
204 int GetBackendStatusPort(
void);
205 int GetBackendStatusPort(
const QString &host);
208 bool GetScopeForAddress(QHostAddress &addr)
const;
209 void SetScopeForAddress(
const QHostAddress &addr);
210 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
211 enum ResolveType : std::int8_t { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
212 QString resolveSettingAddress(
const QString &name,
213 const QString &host = QString(),
214 ResolveType
type = ResolveAny,
215 bool keepscope =
false);
216 static QString resolveAddress(
const QString &host,
217 ResolveType
type = ResolveAny,
218 bool keepscope =
false) ;
219 bool CheckSubnet(
const QAbstractSocket *socket);
220 bool CheckSubnet(
const QHostAddress &peer);
223 void ActivateSettingsCache(
bool activate =
true);
224 void OverrideSettingForSession(
const QString &key,
const QString &value);
225 void ClearOverrideSettingForSession(
const QString &key);
229 void InitPower(
bool Create =
true);
230 void InitLocale(
void);
231 void ReInitLocale(
void);
233 QLocale GetQLocale(
void);
234 void SaveLocaleDefaults(
void);
235 QString GetLanguage(
void);
236 QString GetLanguageAndVariant(
void);
237 void ResetLanguage(
void);
238 QString GetAudioLanguage(
void);
239 QString GetAudioLanguageAndVariant(
void);
240 void ResetAudioLanguage(
void);
241 void ResetSockets(
void);
253 template <
class OBJ,
typename SLOT>
254 typename std::enable_if_t<std::is_member_function_pointer_v<SLOT>,
void>
257 RegisterForPlayback(qobject_cast<QObject*>(sender),
261 void UnregisterForPlayback(QObject *sender);
262 void WantingPlayback(QObject *sender);
263 bool InWantingPlayback(
void);
264 void TVInWantingPlayback(
bool b);
269 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
270 const QString &pluginversion);
276 void SetExiting(
bool exiting =
true);
277 bool IsExiting(
void);
279 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
280 void UnregisterFileForWrite(
const QString &
file);
281 bool IsRegisteredFileForWrite(
const QString &
file);
284 void setTestIntSettings(QMap<QString,int>& overrides);
285 void setTestFloatSettings(QMap<QString,double>& overrides);
286 void setTestStringSettings(QMap<QString,QString>& overrides);
289 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
293 emit TVPlaybackSought();}
301 void TVPlaybackStarted(
void);
304 void TVPlaybackStopped(
void);
305 void TVPlaybackSought(qint64 position);
306 void TVPlaybackSought(
void);
307 void TVPlaybackPaused(
void);
308 void TVPlaybackUnpaused(
void);
309 void TVPlaybackAborted(
void);
310 void TVPlaybackAboutToStart(
void);
311 void TVPlaybackPlaying(
void);
327 bool m_dvbv3 {
false};