MythTV  master
Public Slots | Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
MythContextPrivate Class Reference
Inheritance diagram for MythContextPrivate:
Inheritance graph
[legend]
Collaboration diagram for MythContextPrivate:
Collaboration graph
[legend]

Public Slots

void OnCloseDialog ()
 

Public Member Functions

 MythContextPrivate (MythContext *lparent)
 
 ~MythContextPrivate () override
 
bool Init (bool gui, bool prompt, bool noPrompt, bool ignoreDB)
 
bool FindDatabase (bool prompt, bool noAutodetect)
 Get database connection settings and test connectivity. More...
 
void TempMainWindow (bool languagePrompt=true)
 Setup a minimal themed main window, and prompt for user's language. More...
 
void EndTempWindow (void)
 
bool LoadDatabaseSettings (void)
 Load database and host settings from config.xml, or set some defaults. More...
 
bool SaveDatabaseParams (const DatabaseParams &params, bool force)
 
bool PromptForDatabaseParams (const QString &error)
 
QString TestDBconnection (bool prompt=true)
 Some quick sanity checks before opening a database connection. More...
 
void SilenceDBerrors (void)
 Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently. More...
 
void EnableDBerrors (void)
 
void ResetDatabase (void)
 Called when the user changes the DB connection settings. More...
 
int ChooseBackend (const QString &error)
 Search for backends via UPnP, put up a UI for the user to choose one. More...
 
int UPnPautoconf (int milliSeconds=2000)
 If there is only a single UPnP backend, use it. More...
 
bool DefaultUPnP (QString &error)
 Get the default backend from config.xml, use UPnP to find it. More...
 
bool UPnPconnect (const DeviceLocation *backend, const QString &PIN)
 Query a backend via UPnP for its database connection parameters. More...
 
void ShowGuiStartup (void)
 
bool checkPort (QString &host, int port, int timeLimit)
 Check if a port is open and sort out the link-local scope. More...
 
void processEvents (void)
 
bool saveSettingsCache (void)
 
void loadSettingsCacheOverride (void)
 
void clearSettingsCacheOverride (void)
 

Public Attributes

MythContextm_parent {nullptr}
 
bool m_gui {false}
 Should this context use GUI elements? More...
 
QString m_masterhostname
 master backend hostname More...
 
DatabaseParams m_DBparams
 Current database host & WOL details. More...
 
QString m_DBhostCp
 dbHostName backup More...
 
Configurationm_pConfig {nullptr}
 
bool m_disableeventpopup {false}
 
MythUIHelperm_ui {nullptr}
 
MythContextSlotHandlerm_sh {nullptr}
 
GUIStartupm_guiStartup {nullptr}
 
QEventLoop * m_loop {nullptr}
 
bool m_needsBackend {false}
 
bool m_settingsCacheDirty {false}
 

Protected Member Functions

bool event (QEvent *) override
 
void ShowConnectionFailurePopup (bool persistent)
 
void HideConnectionFailurePopup (void)
 
void ShowVersionMismatchPopup (uint remote_version)
 

Private Attributes

MythConfirmationDialogm_MBEversionPopup {nullptr}
 
int m_registration {-1}
 
QDateTime m_lastCheck
 
QTcpSocket * m_socket {nullptr}
 

Static Private Attributes

static const QString s_settingsToSave []
 

Friends

class MythContextSlotHandler
 

Detailed Description

Definition at line 67 of file mythcontext.cpp.

Constructor & Destructor Documentation

◆ MythContextPrivate()

MythContextPrivate::MythContextPrivate ( MythContext lparent)

Definition at line 241 of file mythcontext.cpp.

◆ ~MythContextPrivate()

MythContextPrivate::~MythContextPrivate ( )
override

Definition at line 249 of file mythcontext.cpp.

Member Function Documentation

◆ Init()

bool MythContextPrivate::Init ( bool  gui,
bool  prompt,
bool  noPrompt,
bool  ignoreDB 
)

Definition at line 334 of file mythcontext.cpp.

Referenced by MythContext::Init().

◆ FindDatabase()

bool MythContextPrivate::FindDatabase ( bool  prompt,
bool  noAutodetect 
)

Get database connection settings and test connectivity.

Can use UPnP AutoDiscovery to locate backends, and get their DB settings. The user can force the AutoDiscovery chooser with the –prompt argument, and disable it by using the –disable-autodiscovery argument. There is also an autoconfigure function, which counts the backends, and if there is exactly one, uses it as above.

Despite its name, the disable argument currently only disables the chooser. If set, autoconfigure will still be attempted in some situations.

Definition at line 410 of file mythcontext.cpp.

Referenced by Init().

◆ TempMainWindow()

void MythContextPrivate::TempMainWindow ( bool  languagePrompt = true)

Setup a minimal themed main window, and prompt for user's language.

Used for warnings before the database is opened, or bootstrapping pages. After using the window, call EndTempWindow().

Bug:
Some of these settings (e.g. window size, theme) seem to be used after the temp window is destroyed.

Definition at line 275 of file mythcontext.cpp.

Referenced by ChooseBackend(), MythContext::Init(), Init(), PromptForDatabaseParams(), and ShowGuiStartup().

◆ EndTempWindow()

void MythContextPrivate::EndTempWindow ( void  )

Definition at line 300 of file mythcontext.cpp.

Referenced by ChooseBackend(), Init(), and PromptForDatabaseParams().

◆ LoadDatabaseSettings()

bool MythContextPrivate::LoadDatabaseSettings ( void  )

Load database and host settings from config.xml, or set some defaults.

Returns
true if config.xml was parsed

Definition at line 535 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ SaveDatabaseParams()

bool MythContextPrivate::SaveDatabaseParams ( const DatabaseParams params,
bool  force 
)

Definition at line 643 of file mythcontext.cpp.

Referenced by FindDatabase(), and MythContext::SaveDatabaseParams().

◆ PromptForDatabaseParams()

bool MythContextPrivate::PromptForDatabaseParams ( const QString &  error)

Definition at line 716 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ TestDBconnection()

QString MythContextPrivate::TestDBconnection ( bool  prompt = true)

Some quick sanity checks before opening a database connection.

Todo:
Rationalise the WOL stuff. We should have one method to wake BEs

Definition at line 809 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ SilenceDBerrors()

void MythContextPrivate::SilenceDBerrors ( void  )

Cause MSqlDatabase::OpenDatabase() and MSqlQuery to fail silently.

This is used when the DB host address is bad, is non-routable, the passwords are bad, or the DB has some other problem.

It prevents hundreds of long TCP/IP timeouts or DB connect errors.

Definition at line 1094 of file mythcontext.cpp.

Referenced by PromptForDatabaseParams(), TempMainWindow(), and TestDBconnection().

◆ EnableDBerrors()

void MythContextPrivate::EnableDBerrors ( void  )

◆ ResetDatabase()

void MythContextPrivate::ResetDatabase ( void  )

Called when the user changes the DB connection settings.

The current DB connections may be invalid (e.g. wrong password), or the user may have changed to a different database host. Either way, any current connections need to be closed so that the new connection can be attempted.

Any cached settings also need to be cleared, so that they can be re-read from the new database

Definition at line 1133 of file mythcontext.cpp.

Referenced by FindDatabase(), SaveDatabaseParams(), and TestDBconnection().

◆ ChooseBackend()

int MythContextPrivate::ChooseBackend ( const QString &  error)

Search for backends via UPnP, put up a UI for the user to choose one.

Definition at line 1143 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ UPnPautoconf()

int MythContextPrivate::UPnPautoconf ( int  milliSeconds = 2000)

If there is only a single UPnP backend, use it.

This does not prompt for PIN entry. If the backend requires one, it will fail, and the caller needs to put up a UI to ask for one.

Definition at line 1170 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ DefaultUPnP()

bool MythContextPrivate::DefaultUPnP ( QString &  error)

Get the default backend from config.xml, use UPnP to find it.

Sets a string if there any connection problems

Definition at line 1239 of file mythcontext.cpp.

Referenced by FindDatabase().

◆ UPnPconnect()

bool MythContextPrivate::UPnPconnect ( const DeviceLocation backend,
const QString &  PIN 
)

Query a backend via UPnP for its database connection parameters.

Definition at line 1310 of file mythcontext.cpp.

Referenced by DefaultUPnP(), and UPnPautoconf().

◆ ShowGuiStartup()

void MythContextPrivate::ShowGuiStartup ( void  )

Definition at line 1064 of file mythcontext.cpp.

Referenced by TestDBconnection().

◆ checkPort()

bool MythContextPrivate::checkPort ( QString &  host,
int  port,
int  timeLimit 
)

Check if a port is open and sort out the link-local scope.

Parameters
hostHost or IP address. Will be updated with link-local scope if needed.
portPort number to check.
timeLimitLimit in seconds for testing.

Definition at line 325 of file mythcontext.cpp.

Referenced by TestDBconnection().

◆ processEvents()

void MythContextPrivate::processEvents ( void  )

Definition at line 1457 of file mythcontext.cpp.

Referenced by ShowGuiStartup(), and TestDBconnection().

◆ saveSettingsCache()

bool MythContextPrivate::saveSettingsCache ( void  )

Definition at line 1477 of file mythcontext.cpp.

Referenced by MythContext::saveSettingsCache().

◆ loadSettingsCacheOverride()

void MythContextPrivate::loadSettingsCacheOverride ( void  )

Definition at line 1501 of file mythcontext.cpp.

Referenced by Init().

◆ clearSettingsCacheOverride()

void MythContextPrivate::clearSettingsCacheOverride ( void  )

Definition at line 1522 of file mythcontext.cpp.

Referenced by saveSettingsCache().

◆ event()

bool MythContextPrivate::event ( QEvent *  e)
overrideprotected

Definition at line 1353 of file mythcontext.cpp.

◆ ShowConnectionFailurePopup()

void MythContextPrivate::ShowConnectionFailurePopup ( bool  persistent)
protected

Definition at line 1380 of file mythcontext.cpp.

Referenced by event().

◆ HideConnectionFailurePopup()

void MythContextPrivate::HideConnectionFailurePopup ( void  )
protected

Definition at line 1414 of file mythcontext.cpp.

Referenced by event().

◆ ShowVersionMismatchPopup()

void MythContextPrivate::ShowVersionMismatchPopup ( uint  remote_version)
protected

Definition at line 1430 of file mythcontext.cpp.

Referenced by event().

◆ OnCloseDialog

void MythContextPrivate::OnCloseDialog ( )
slot

Friends And Related Function Documentation

◆ MythContextSlotHandler

friend class MythContextSlotHandler
friend

Definition at line 69 of file mythcontext.cpp.

Member Data Documentation

◆ m_parent

MythContext* MythContextPrivate::m_parent {nullptr}

Definition at line 116 of file mythcontext.cpp.

Referenced by PromptForDatabaseParams().

◆ m_gui

bool MythContextPrivate::m_gui {false}

Should this context use GUI elements?

Definition at line 119 of file mythcontext.cpp.

Referenced by FindDatabase(), Init(), loadSettingsCacheOverride(), PromptForDatabaseParams(), saveSettingsCache(), ShowGuiStartup(), and TestDBconnection().

◆ m_masterhostname

QString MythContextPrivate::m_masterhostname

master backend hostname

Definition at line 121 of file mythcontext.cpp.

◆ m_DBparams

DatabaseParams MythContextPrivate::m_DBparams

◆ m_DBhostCp

QString MythContextPrivate::m_DBhostCp

dbHostName backup

Definition at line 124 of file mythcontext.cpp.

Referenced by EnableDBerrors(), SilenceDBerrors(), and TestDBconnection().

◆ m_pConfig

Configuration* MythContextPrivate::m_pConfig {nullptr}

◆ m_disableeventpopup

bool MythContextPrivate::m_disableeventpopup {false}

Definition at line 128 of file mythcontext.cpp.

Referenced by event(), and MythContext::SetDisableEventPopup().

◆ m_ui

MythUIHelper* MythContextPrivate::m_ui {nullptr}

◆ m_sh

MythContextSlotHandler* MythContextPrivate::m_sh {nullptr}

◆ m_guiStartup

GUIStartup* MythContextPrivate::m_guiStartup {nullptr}

◆ m_loop

QEventLoop* MythContextPrivate::m_loop {nullptr}

◆ m_needsBackend

bool MythContextPrivate::m_needsBackend {false}

Definition at line 134 of file mythcontext.cpp.

Referenced by Init(), MythContext::MythContext(), and TestDBconnection().

◆ m_settingsCacheDirty

bool MythContextPrivate::m_settingsCacheDirty {false}

Definition at line 135 of file mythcontext.cpp.

Referenced by MythContext::Init(), and saveSettingsCache().

◆ m_MBEversionPopup

MythConfirmationDialog* MythContextPrivate::m_MBEversionPopup {nullptr}
private

◆ m_registration

int MythContextPrivate::m_registration {-1}
private

◆ m_lastCheck

QDateTime MythContextPrivate::m_lastCheck
private

Definition at line 140 of file mythcontext.cpp.

Referenced by HideConnectionFailurePopup(), and ShowConnectionFailurePopup().

◆ m_socket

QTcpSocket* MythContextPrivate::m_socket {nullptr}
private

Definition at line 141 of file mythcontext.cpp.

◆ s_settingsToSave

const QString MythContextPrivate::s_settingsToSave
staticprivate
Initial value:
=
{ "Theme", "Language", "Country", "GuiHeight",
"GuiOffsetX", "GuiOffsetY", "GuiWidth", "RunFrontendInWindow",
"AlwaysOnTop", "HideMouseCursor", "ThemePainter", "libCECEnabled",
"StartupScreenDelay" }

Definition at line 142 of file mythcontext.cpp.

Referenced by clearSettingsCacheOverride(), loadSettingsCacheOverride(), and saveSettingsCache().


The documentation for this class was generated from the following file: