1 #ifndef MYTHCORECONTEXT_H_
2 #define MYTHCORECONTEXT_H_
6 #include <QHostAddress>
50 void SetLocalHostname(
const QString &
hostname);
55 bool SafeConnectToMasterServer(
bool blockingClient =
true,
56 bool openEventSocket =
true);
57 bool ConnectToMasterServer(
bool blockingClient =
true,
58 bool openEventSocket =
true);
61 const QString &announcement,
62 bool *proto_mismatch =
nullptr,
64 std::chrono::milliseconds setup_timeout = -1ms);
68 bool SetupCommandSocket(
MythSocket *serverSock,
const QString &announcement,
69 std::chrono::milliseconds
timeout,
bool &proto_mismatch);
73 bool error_dialog_desired =
false);
75 static QString GenMythURL(
const QString& host = QString(),
int port = 0,
76 QString path = QString(),
77 const QString& storageGroup = QString());
79 QString GetMasterHostPrefix(
const QString &storageGroup = QString(),
80 const QString &path = QString());
81 QString GetMasterHostName(
void);
82 QString GetHostName(
void);
83 QString GetFilePrefix(
void);
85 bool IsConnectedToMaster(
void);
86 void SetAsBackend(
bool backend);
87 bool IsBackend(
void)
const;
88 void SetAsFrontend(
bool frontend);
89 bool IsFrontend(
void)
const;
90 bool IsFrontendOnly(
void);
91 bool IsMasterHost(
void);
93 bool IsMasterHost(
const QString &host);
95 static bool BackendIsRunning(
void);
97 bool IsThisBackend(
const QString &addr);
98 bool IsThisHost(
const QString &addr);
99 bool IsThisHost(
const QString &addr,
const QString &host);
101 void BlockShutdown(
void);
102 void AllowShutdown(
void);
103 bool IsBlockingClient(
void)
const;
105 void SetWOLAllowed(
bool allow);
106 bool IsWOLAllowed()
const;
108 bool SendReceiveStringList(QStringList &strlist,
bool quickTimeout =
false,
113 void SendHostSystemEvent(
const QString &msg,
const QString &
hostname,
114 const QString &
args);
116 void SetGUIObject(QObject *gui);
117 QObject *GetGUIObject(
void);
118 QObject *GetGUIContext(
void);
119 bool HasGUI(
void)
const;
120 bool IsUIThread(
void);
126 bool IsDatabaseIgnored(
void)
const;
128 void SaveSetting(
const QString &key,
int newValue);
129 void SaveSetting(
const QString &key,
const QString &newValue);
130 QString GetSetting(
const QString &key,
const QString &defaultval =
"");
132 template <
typename T>
133 typename std::enable_if_t<std::chrono::__is_duration<T>::value,
void>
135 { SaveSetting(key,
static_cast<int>(newValue.count())); }
137 bool SaveSettingOnHost(
const QString &key,
const QString &newValue,
138 const QString &host);
140 { SaveSetting(key,
static_cast<int>(newValue)); }
143 bool GetBoolSetting(
const QString &key,
bool defaultval =
false);
144 int GetNumSetting(
const QString &key,
int defaultval = 0);
145 template <
typename T>
146 typename std::enable_if_t<std::chrono::__is_duration<T>::value, T>
148 {
return T(GetNumSetting(key,
static_cast<int>(defaultval.count()))); }
149 int GetBoolSetting(
const QString &key,
int defaultval) =
delete;
150 bool GetNumSetting(
const QString &key,
bool defaultvalue) =
delete;
151 double GetFloatSetting(
const QString &key,
double defaultval = 0.0);
152 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
153 double& forced_aspect,
double &refresh_rate,
155 void GetResolutionSetting(
const QString &
type,
int &width,
int &height,
158 QString GetSettingOnHost(
const QString &key,
const QString &host,
159 const QString &defaultval =
"");
160 bool GetBoolSettingOnHost(
const QString &key,
const QString &host,
161 bool defaultval =
false);
162 int GetNumSettingOnHost(
const QString &key,
const QString &host,
164 int GetBoolSettingOnHost(
const QString &key,
const QString &host,
165 int defaultval) =
delete;
166 bool GetNumSettingOnHost(
const QString &key,
const QString &host,
167 bool defaultval =
false) =
delete;
168 double GetFloatSettingOnHost(
const QString &key,
const QString &host,
169 double defaultval = 0.0);
171 QString GetBackendServerIP(
void);
172 QString GetBackendServerIP(
const QString &host);
173 QString GetBackendServerIP4(
void);
174 QString GetBackendServerIP4(
const QString &host);
175 QString GetBackendServerIP6(
void);
176 QString GetBackendServerIP6(
const QString &host);
177 QString GetMasterServerIP(
void);
178 static int GetMasterServerPort(
void);
179 int GetMasterServerStatusPort(
void);
180 int GetBackendServerPort(
void);
181 int GetBackendServerPort(
const QString &host);
182 static void ClearBackendServerPortCache();
183 int GetBackendStatusPort(
void);
184 int GetBackendStatusPort(
const QString &host);
187 bool GetScopeForAddress(QHostAddress &addr)
const;
188 void SetScopeForAddress(
const QHostAddress &addr);
189 void SetScopeForAddress(
const QHostAddress &addr,
int scope);
190 enum ResolveType : std::int8_t { ResolveAny = -1, ResolveIPv4 = 0, ResolveIPv6 = 1 };
191 QString resolveSettingAddress(
const QString &name,
192 const QString &host = QString(),
193 ResolveType
type = ResolveAny,
194 bool keepscope =
false);
195 static QString resolveAddress(
const QString &host,
196 ResolveType
type = ResolveAny,
197 bool keepscope =
false) ;
198 bool CheckSubnet(
const QAbstractSocket *socket);
199 bool CheckSubnet(
const QHostAddress &peer);
202 void ActivateSettingsCache(
bool activate =
true);
203 void OverrideSettingForSession(
const QString &key,
const QString &value);
204 void ClearOverrideSettingForSession(
const QString &key);
208 void InitPower(
bool Create =
true);
209 void InitLocale(
void);
210 void ReInitLocale(
void);
212 QLocale GetQLocale(
void);
213 void SaveLocaleDefaults(
void);
214 QString GetLanguage(
void);
215 QString GetLanguageAndVariant(
void);
216 void ResetLanguage(
void);
217 QString GetAudioLanguage(
void);
218 QString GetAudioLanguageAndVariant(
void);
219 void ResetAudioLanguage(
void);
220 void ResetSockets(
void);
232 template <
class OBJ,
typename SLOT>
233 typename std::enable_if_t<std::is_member_function_pointer_v<SLOT>,
void>
236 RegisterForPlayback(qobject_cast<QObject*>(sender),
240 void UnregisterForPlayback(QObject *sender);
241 void WantingPlayback(QObject *sender);
242 bool InWantingPlayback(
void);
243 void TVInWantingPlayback(
bool b);
248 static bool TestPluginVersion(
const QString &name,
const QString &libversion,
249 const QString &pluginversion);
255 void SetExiting(
bool exiting =
true);
256 bool IsExiting(
void);
258 void RegisterFileForWrite(
const QString &
file, uint64_t size = 0LL);
259 void UnregisterFileForWrite(
const QString &
file);
260 bool IsRegisteredFileForWrite(
const QString &
file);
263 void setTestIntSettings(QMap<QString,int>& overrides);
264 void setTestFloatSettings(QMap<QString,double>& overrides);
265 void setTestStringSettings(QMap<QString,QString>& overrides);
268 void WaitUntilSignals(std::vector<CoreWaitInfo> & sigs)
const;
272 emit TVPlaybackSought();}
280 void TVPlaybackStarted(
void);
283 void TVPlaybackStopped(
void);
284 void TVPlaybackSought(qint64 position);
285 void TVPlaybackSought(
void);
286 void TVPlaybackPaused(
void);
287 void TVPlaybackUnpaused(
void);
288 void TVPlaybackAborted(
void);
289 void TVPlaybackAboutToStart(
void);
290 void TVPlaybackPlaying(
void);
306 bool m_dvbv3 {
false};