1 #ifndef MYTHCORECONTEXT_H_
2 #define MYTHCORECONTEXT_H_
6 #include <QHostAddress>
72 void SetLocalHostname(
const QString &
hostname);
77 bool SafeConnectToMasterServer(
bool blockingClient =
true,
78 bool openEventSocket =
true);
79 bool ConnectToMasterServer(
bool blockingClient =
true,
80 bool openEventSocket =
true);
83 const QString &announcement,
84 bool *proto_mismatch =
nullptr,
86 std::chrono::milliseconds setup_timeout = -1ms);
90 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
91 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
95 bool error_dialog_desired =
false);
97 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
98 QString path = QString(),
99 const QString& storageGroup = QString());
101 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
102 const QString &path = QString());
103 QString GetMasterHostName(
void);
104 QString GetHostName(
void);
105 QString GetFilePrefix(
void);
107 bool IsConnectedToMaster(
void);
108 void SetAsBackend(
bool backend);
109 bool IsBackend(
void)
const;
110 void SetAsFrontend(
bool frontend);
111 bool IsFrontend(
void)
const;
112 bool IsFrontendOnly(
void);
113 bool IsMasterHost(
void);
115 bool IsMasterHost(
const QString &host);
117 static bool BackendIsRunning(
void);
119 bool IsThisBackend(
const QString &addr);
120 bool IsThisHost(
const QString &addr);
121 bool IsThisHost(
const QString &addr,
const QString &host);
123 void BlockShutdown(
void);
124 void AllowShutdown(
void);
125 bool IsBlockingClient(
void)
const;
127 void SetWOLAllowed(
bool allow);
128 bool IsWOLAllowed()
const;
130 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
135 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
136 const QString &
args);
138 void SetGUIObject(QObject *gui);
139 QObject *GetGUIObject(
void);
140 QObject *GetGUIContext(
void);
141 bool HasGUI(
void)
const;
142 bool IsUIThread(
void);
148 bool IsDatabaseIgnored(
void)
const;
150 void SaveSetting(
const QString &key,
int newValue);
151 void SaveSetting(
const QString &key,
const QString &newValue);
152 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
154 template <
typename T>
155 typename std::enable_if_t<std::chrono::__is_duration<T>::value,
void>
157 { SaveSetting(key,
static_cast<int>(newValue.count())); }
159 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
160 const QString &host);
162 { SaveSetting(key,
static_cast<int>(newValue)); }
165 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
166 int GetNumSetting(
const QString &key,
int defaultval = 0);
167 template <
typename T>
168 typename std::enable_if_t<std::chrono::__is_duration<T>::value, T>
170 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
171 int GetBoolSetting(
const QString &key,
int defaultval) =
delete;
172 bool GetNumSetting(
const QString &key,
bool defaultvalue) =
delete;
173 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
174 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
175 double& forced_aspect,
double &refresh_rate,
177 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
180 QString GetSettingOnHost(
const QString &key,
const QString &host,
181 const QString &defaultval =
"");
182 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
183 bool defaultval =
false);
184 int GetNumSettingOnHost(
const QString &key,
const QString &host,
186 int GetBoolSettingOnHost(
const QString &key,
const QString &host,
187 int defaultval) =
delete;
188 bool GetNumSettingOnHost(
const QString &key,
const QString &host,
189 bool defaultval =
false) =
delete;
190 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
191 double defaultval = 0.0);
193 QString GetBackendServerIP(
void);
194 QString GetBackendServerIP(
const QString &host);
195 QString GetBackendServerIP4(
void);
196 QString GetBackendServerIP4(
const QString &host);
197 QString GetBackendServerIP6(
void);
198 QString GetBackendServerIP6(
const QString &host);
199 QString GetMasterServerIP(
void);
200 static int GetMasterServerPort(
void);
201 int GetMasterServerStatusPort(
void);
202 int GetBackendServerPort(
void);
203 int GetBackendServerPort(
const QString &host);
204 static void ClearBackendServerPortCache();
205 int GetBackendStatusPort(
void);
206 int GetBackendStatusPort(
const QString &host);
209 bool GetScopeForAddress(QHostAddress &addr)
const;
210 void SetScopeForAddress(
const QHostAddress &addr);
211 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
212 enum ResolveType { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
213 QString resolveSettingAddress(
const QString &name,
214 const QString &host = QString(),
215 ResolveType
type = ResolveAny,
216 bool keepscope =
false);
217 static QString resolveAddress(
const QString &host,
218 ResolveType
type = ResolveAny,
219 bool keepscope =
false) ;
220 bool CheckSubnet(
const QAbstractSocket *socket);
221 bool CheckSubnet(
const QHostAddress &peer);
224 void ActivateSettingsCache(
bool activate =
true);
225 void OverrideSettingForSession(
const QString &key,
const QString &value);
226 void ClearOverrideSettingForSession(
const QString &key);
230 void InitPower(
bool Create =
true);
231 void InitLocale(
void);
232 void ReInitLocale(
void);
234 QLocale GetQLocale(
void);
235 void SaveLocaleDefaults(
void);
236 QString GetLanguage(
void);
237 QString GetLanguageAndVariant(
void);
238 void ResetLanguage(
void);
239 void ResetSockets(
void);
251 template <
class OBJ,
typename SLOT>
252 typename std::enable_if_t<std::is_member_function_pointer_v<SLOT>,
void>
255 RegisterForPlayback(qobject_cast<QObject*>(sender),
259 void UnregisterForPlayback(QObject *sender);
260 void WantingPlayback(QObject *sender);
261 bool InWantingPlayback(
void);
262 void TVInWantingPlayback(
bool b);
267 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
268 const QString &pluginversion);
274 void SetExiting(
bool exiting =
true);
275 bool IsExiting(
void);
277 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
278 void UnregisterFileForWrite(
const QString &
file);
279 bool IsRegisteredFileForWrite(
const QString &
file);
282 void setTestIntSettings(QMap<QString,int>& overrides);
283 void setTestFloatSettings(QMap<QString,double>& overrides);
284 void setTestStringSettings(QMap<QString,QString>& overrides);
287 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
291 emit TVPlaybackSought();}
299 void TVPlaybackStarted(
void);
302 void TVPlaybackStopped(
void);
303 void TVPlaybackSought(qint64 position);
304 void TVPlaybackSought(
void);
305 void TVPlaybackPaused(
void);
306 void TVPlaybackUnpaused(
void);
307 void TVPlaybackAborted(
void);
308 void TVPlaybackAboutToStart(
void);
309 void TVPlaybackPlaying(
void);
320 QMap<QString,int> m_testOverrideInts {};
321 QMap<QString,double> m_testOverrideFloats {};
322 QMap<QString,QString> m_testOverrideStrings {};
325 bool m_dvbv3 {
false};